Improved code readability

Changed table echo to printf for more readable code
Wrapped sql_dump error message in __d(), as discussed here:
4c4fdc6f70 (commitcomment-3155723)
and here:
https://github.com/cakephp/cakephp/pull/1491/files#r5646701
This commit is contained in:
Marc Würth 2013-08-08 00:41:03 +02:00
parent 481d3920ae
commit 14f876fbc9

View file

@ -58,19 +58,27 @@ if ($noLogs || isset($_forced_from_dbo_)):
} }
foreach ($i['params'] as $bindKey => $bindVal) { foreach ($i['params'] as $bindKey => $bindVal) {
if ($bindType === true) { if ($bindType === true) {
$bindParam .= h($bindKey) ." => " . h($bindVal) . ", "; $bindParam .= h($bindKey) . " => " . h($bindVal) . ", ";
} else { } else {
$bindParam .= h($bindVal) . ", "; $bindParam .= h($bindVal) . ", ";
} }
} }
$i['query'] .= " , params[ " . rtrim($bindParam, ', ') . " ]"; $i['query'] .= " , params[ " . rtrim($bindParam, ', ') . " ]";
} }
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"; printf('<tr><td>%d</td><td>%s</td><td>%s</td><td style="text-align: right">%d</td><td style="text-align: right">%d</td><td style="text-align: right">%d</td></tr>%s',
$k + 1,
h($i['query']),
$i['error'],
$i['affected'],
$i['numRows'],
$i['took'],
"\n"
);
endforeach; endforeach;
?> ?>
</tbody></table> </tbody></table>
<?php <?php
endforeach; endforeach;
else: else:
echo '<p>Encountered unexpected $logs cannot generate SQL log</p>'; printf('<p>%s</p>', __d('cake_dev', 'Encountered unexpected %s. Cannot generate SQL log.', '$logs'));
endif; endif;