cakephp2-php8/cake/libs/view/elements/sql_dump.ctp
Mark Story 08e7bcb7ab Merge branch '1.3' into integration
Conflicts:
	app/config/core.php
	cake/console/libs/acl.php
	cake/console/templates/skel/config/core.php
	cake/console/templates/skel/webroot/test.php
	cake/dispatcher.php
	cake/libs/view/errors/missing_action.ctp
	cake/libs/view/helpers/form.php
	cake/tests/cases/libs/cache/memcache.test.php
	cake/tests/cases/libs/controller/controller.test.php
	cake/tests/cases/libs/log/file_log.test.php
	cake/tests/cases/libs/model/cake_schema.test.php
	cake/tests/cases/libs/router.test.php
	cake/tests/cases/libs/view/helpers/ajax.test.php
	cake/tests/groups/bake.group.php
	cake/tests/groups/behaviors.group.php
	cake/tests/groups/i18n.group.php
	cake/tests/groups/javascript.group.php
	cake/tests/lib/reporter/cake_cli_reporter.php
2010-10-31 21:56:59 -04:00

61 lines
2.1 KiB
PHP

<?php
/**
* SQL Dump element. Dumps out SQL log information
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake
* @subpackage cake.cake.libs.view.templates.elements
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
if (!class_exists('ConnectionManager') || Configure::read('debug') < 2) {
return false;
}
$noLogs = !isset($logs);
if ($noLogs):
$sources = ConnectionManager::sourceList();
$logs = array();
foreach ($sources as $source):
$db =& ConnectionManager::getDataSource($source);
if (!$db->isInterfaceSupported('getLog')):
continue;
endif;
$logs[$source] = $db->getLog();
endforeach;
endif;
if ($noLogs || isset($_forced_from_dbo_)):
foreach ($logs as $source => $logInfo):
$text = $logInfo['count'] > 1 ? 'queries' : 'query';
printf(
'<table class="cake-sql-log" id="cakeSqlLog_%s" summary="Cake SQL Log" cellspacing="0" border = "0">',
preg_replace('/[^A-Za-z0-9_]/', '_', uniqid(time(), true))
);
printf('<caption>(%s) %s %s took %s ms</caption>', $source, $logInfo['count'], $text, $logInfo['time']);
?>
<thead>
<tr><th>Nr</th><th>Query</th><th>Error</th><th>Affected</th><th>Num. rows</th><th>Took (ms)</th></tr>
</thead>
<tbody>
<?php
foreach ($logInfo['log'] as $k => $i) :
echo "<tr><td>" . ($k + 1) . "</td><td>" . h($i['query']) . "</td><td>{$i['error']}</td><td style = \"text-align: right\">{$i['affected']}</td><td style = \"text-align: right\">{$i['numRows']}</td><td style = \"text-align: right\">{$i['took']}</td></tr>\n";
endforeach;
?>
</tbody></table>
<?php
endforeach;
else:
echo '<p>Encountered unexpected $logs cannot generate SQL log</p>';
endif;
?>