mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
3303a2cda1
Conflicts: lib/Cake/Console/Templates/skel/Config/Schema/db_acl.php lib/Cake/Console/Templates/skel/Config/Schema/i18n.php lib/Cake/Console/Templates/skel/Config/Schema/sessions.php lib/Cake/Console/Templates/skel/Config/acl.ini.php lib/Cake/Console/Templates/skel/Config/acl.php lib/Cake/Console/Templates/skel/Config/bootstrap.php lib/Cake/Console/Templates/skel/Config/core.php lib/Cake/Console/Templates/skel/Config/database.php.default lib/Cake/Console/Templates/skel/Config/email.php.default lib/Cake/Console/Templates/skel/Config/routes.php lib/Cake/Console/Templates/skel/Console/Command/AppShell.php lib/Cake/Console/Templates/skel/Console/cake.bat lib/Cake/Console/Templates/skel/Console/cake.php lib/Cake/Console/Templates/skel/Controller/AppController.php lib/Cake/Console/Templates/skel/Controller/PagesController.php lib/Cake/Console/Templates/skel/Model/AppModel.php lib/Cake/Console/Templates/skel/View/Errors/error400.ctp lib/Cake/Console/Templates/skel/View/Errors/error500.ctp lib/Cake/Console/Templates/skel/View/Helper/AppHelper.php lib/Cake/Console/Templates/skel/View/Layouts/Emails/html/default.ctp lib/Cake/Console/Templates/skel/View/Layouts/ajax.ctp lib/Cake/Console/Templates/skel/View/Layouts/default.ctp lib/Cake/Console/Templates/skel/View/Layouts/error.ctp lib/Cake/Console/Templates/skel/View/Layouts/flash.ctp lib/Cake/Console/Templates/skel/View/Pages/home.ctp lib/Cake/Console/Templates/skel/index.php lib/Cake/Console/Templates/skel/webroot/index.php lib/Cake/Console/Templates/skel/webroot/test.php
76 lines
2.5 KiB
PHP
76 lines
2.5 KiB
PHP
<?php
|
|
/**
|
|
* SQL Dump element. Dumps out SQL log information
|
|
*
|
|
* PHP 5
|
|
*
|
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
|
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
*
|
|
* Licensed under The MIT License
|
|
* For full copyright and license information, please see the LICENSE.txt
|
|
* Redistributions of files must retain the above copyright notice.
|
|
*
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
* @link http://cakephp.org CakePHP(tm) Project
|
|
* @package Cake.View.Elements
|
|
* @since CakePHP(tm) v 1.3
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
|
*/
|
|
|
|
if (!class_exists('ConnectionManager') || Configure::read('debug') < 2) {
|
|
return false;
|
|
}
|
|
$noLogs = !isset($sqlLogs);
|
|
if ($noLogs):
|
|
$sources = ConnectionManager::sourceList();
|
|
|
|
$sqlLogs = array();
|
|
foreach ($sources as $source):
|
|
$db = ConnectionManager::getDataSource($source);
|
|
if (!method_exists($db, 'getLog')):
|
|
continue;
|
|
endif;
|
|
$sqlLogs[$source] = $db->getLog();
|
|
endforeach;
|
|
endif;
|
|
|
|
if ($noLogs || isset($_forced_from_dbo_)):
|
|
foreach ($sqlLogs as $source => $logInfo):
|
|
$text = $logInfo['count'] > 1 ? 'queries' : 'query';
|
|
printf(
|
|
'<table class="cake-sql-log" id="cakeSqlLog_%s" summary="Cake SQL Log" cellspacing="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) :
|
|
$i += array('error' => '');
|
|
if (!empty($i['params']) && is_array($i['params'])) {
|
|
$bindParam = $bindType = null;
|
|
if (preg_match('/.+ :.+/', $i['query'])) {
|
|
$bindType = true;
|
|
}
|
|
foreach ($i['params'] as $bindKey => $bindVal) {
|
|
if ($bindType === true) {
|
|
$bindParam .= h($bindKey) ." => " . h($bindVal) . ", ";
|
|
} else {
|
|
$bindParam .= h($bindVal) . ", ";
|
|
}
|
|
}
|
|
$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";
|
|
endforeach;
|
|
?>
|
|
</tbody></table>
|
|
<?php
|
|
endforeach;
|
|
else:
|
|
echo '<p>Encountered unexpected $sqlLogs cannot generate SQL log</p>';
|
|
endif;
|