Merge pull request #4582 from tractorcow/pulls/4.0/showqueries-params

API showqueries=1 now shows parameters
This commit is contained in:
Loz Calver 2015-09-24 16:27:16 +01:00
commit 23bd11dd91

View File

@ -132,7 +132,8 @@ abstract class SS_Database {
$sql,
function($sql) use($connector, $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 callable $callback Callback to execute code
* @param array $parameters Parameters to display
* @return mixed Result of query
*/
protected function benchmarkQuery($sql, $callback) {
protected function benchmarkQuery($sql, $callback, $parameters = null) {
if (isset($_REQUEST['showqueries']) && Director::isDev()) {
$starttime = microtime(true);
$result = $callback($sql);
$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;
} else {
return $callback($sql);