mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #5606 from Firesphere/patch-1
Show the query number as part of debugging
This commit is contained in:
commit
803cef4f3c
@ -15,6 +15,13 @@ abstract class SS_Database {
|
||||
* @var DBConnector
|
||||
*/
|
||||
protected $connector = null;
|
||||
|
||||
/**
|
||||
* Amount of queries executed, for debugging purposes.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $queryCount = 0;
|
||||
|
||||
/**
|
||||
* Get the current connector
|
||||
@ -171,6 +178,7 @@ abstract class SS_Database {
|
||||
*/
|
||||
protected function benchmarkQuery($sql, $callback, $parameters = null) {
|
||||
if (isset($_REQUEST['showqueries']) && Director::isDev()) {
|
||||
$this->queryCount++;
|
||||
$starttime = microtime(true);
|
||||
$result = $callback($sql);
|
||||
$endtime = round(microtime(true) - $starttime, 4);
|
||||
@ -178,7 +186,7 @@ abstract class SS_Database {
|
||||
if($parameters) {
|
||||
$message .= "\nparams: \"" . implode('", "', $parameters) . '"';
|
||||
}
|
||||
Debug::message("\n{$message}\n{$endtime}s\n", false);
|
||||
Debug::message("\n$this->queryCount: {$message}\n{$endtime}s\n", false);
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user