Changing sql_dump element so it only shows if there is no $logs variable set in the view. Overwriting it could adversely effect helper references. Fixes #998

This commit is contained in:
mark_story 2010-08-10 23:09:27 -04:00
parent 1371cefc3d
commit da9c0da626

View file

@ -20,9 +20,9 @@
if (!class_exists('ConnectionManager') || Configure::read('debug') < 2) { if (!class_exists('ConnectionManager') || Configure::read('debug') < 2) {
return false; return false;
} }
$sources = ConnectionManager::sourceList();
if (!isset($logs)): if (!isset($logs)):
$sources = ConnectionManager::sourceList();
$logs = array(); $logs = array();
foreach ($sources as $source): foreach ($sources as $source):
$db =& ConnectionManager::getDataSource($source); $db =& ConnectionManager::getDataSource($source);
@ -31,24 +31,27 @@ if (!isset($logs)):
endif; endif;
$logs[$source] = $db->getLog(); $logs[$source] = $db->getLog();
endforeach; endforeach;
endif;
foreach ($logs as $source => $logInfo):
$text = $logInfo['count'] > 1 ? 'queries' : 'query'; foreach ($logs as $source => $logInfo):
printf( $text = $logInfo['count'] > 1 ? 'queries' : 'query';
'<table class="cake-sql-log" id="cakeSqlLog_%s" summary="Cake SQL Log" cellspacing="0" border = "0">', printf(
preg_replace('/[^A-Za-z0-9_]/', '_', uniqid(time(), true)) '<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']); );
?> 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>
</thead> <tr><th>Nr</th><th>Query</th><th>Error</th><th>Affected</th><th>Num. rows</th><th>Took (ms)</th></tr>
<tbody> </thead>
<?php <tbody>
foreach ($logInfo['log'] as $k => $i) : <?php
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"; 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; endforeach;
endif;
?> ?>
</tbody></table>
<?php endforeach; ?>