Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Added query duration to debug bar #7323

Merged
merged 1 commit into from
Oct 31, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions system/modules/core/library/Contao/Database/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ abstract class Statement
*/
protected $strQuery;

/**
* Query start
* @var int
*/
protected $intQueryStart;

/**
* Query end
* @var int
*/
protected $intQueryEnd;

/**
* Autocommit indicator
* @var boolean
Expand Down Expand Up @@ -278,10 +290,12 @@ public function query($strQuery='')
}

// Execute the query
$this->intQueryStart = microtime(true);
if (($this->resResult = $this->execute_query()) == false)
{
throw new \Exception(sprintf('Query error: %s (%s)', $this->error, $this->strQuery));
}
$this->intQueryEnd = microtime(true);

// No result set available
if (!is_resource($this->resResult) && !is_object($this->resResult))
Expand Down Expand Up @@ -370,6 +384,7 @@ protected function debugQuery($objResult=null)
}

$arrData['query'] = specialchars($this->strQuery);
$arrData['duration'] = \System::getFormattedNumber((($this->intQueryEnd - $this->intQueryStart) * 1000), 3) . ' ms';

if ($objResult === null || strncasecmp($this->strQuery, 'SELECT', 6) !== 0)
{
Expand Down