mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API showqueries=1 now shows parameters
This commit is contained in:
parent
143e4eae5f
commit
ee639deedb
@ -132,7 +132,8 @@ abstract class SS_Database {
|
|||||||
$sql,
|
$sql,
|
||||||
function($sql) use($connector, $parameters, $errorLevel) {
|
function($sql) use($connector, $parameters, $errorLevel) {
|
||||||
return $connector->preparedQuery($sql, $parameters, $errorLevel);
|
return $connector->preparedQuery($sql, $parameters, $errorLevel);
|
||||||
}
|
},
|
||||||
|
$parameters
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,14 +166,20 @@ abstract class SS_Database {
|
|||||||
*
|
*
|
||||||
* @param string $sql Query to run, and single parameter to callback
|
* @param string $sql Query to run, and single parameter to callback
|
||||||
* @param callable $callback Callback to execute code
|
* @param callable $callback Callback to execute code
|
||||||
|
* @param array $parameters Parameters to display
|
||||||
* @return mixed Result of query
|
* @return mixed Result of query
|
||||||
*/
|
*/
|
||||||
protected function benchmarkQuery($sql, $callback) {
|
protected function benchmarkQuery($sql, $callback, $parameters = null) {
|
||||||
if (isset($_REQUEST['showqueries']) && Director::isDev()) {
|
if (isset($_REQUEST['showqueries']) && Director::isDev()) {
|
||||||
$starttime = microtime(true);
|
$starttime = microtime(true);
|
||||||
$result = $callback($sql);
|
$result = $callback($sql);
|
||||||
$endtime = round(microtime(true) - $starttime, 4);
|
$endtime = round(microtime(true) - $starttime, 4);
|
||||||
Debug::message("\n$sql\n{$endtime}s\n", false);
|
$message = $sql;
|
||||||
|
if($parameters) {
|
||||||
|
$message .= "\nparams: \"" . implode('", "', $parameters) . '"';
|
||||||
|
}
|
||||||
|
Debug::message("\n{$message}\n{$endtime}s\n", false);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
} else {
|
} else {
|
||||||
return $callback($sql);
|
return $callback($sql);
|
||||||
|
Loading…
Reference in New Issue
Block a user