mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 06:07:39 +02:00
DibiProfiler: EXPLAIN is executed at shutdown [Closes #17]
This commit is contained in:
@@ -112,7 +112,7 @@ class DibiProfiler extends DibiObject implements IDibiProfiler, IDebugPanel
|
|||||||
{
|
{
|
||||||
if ($event & self::QUERY) dibi::$numOfQueries++;
|
if ($event & self::QUERY) dibi::$numOfQueries++;
|
||||||
dibi::$elapsedTime = FALSE;
|
dibi::$elapsedTime = FALSE;
|
||||||
self::$tickets[] = array($connection, $event, trim($sql), -microtime(TRUE), NULL, NULL);
|
self::$tickets[] = array($connection, $event, trim($sql), -microtime(TRUE), NULL);
|
||||||
end(self::$tickets);
|
end(self::$tickets);
|
||||||
return key(self::$tickets);
|
return key(self::$tickets);
|
||||||
}
|
}
|
||||||
@@ -155,15 +155,6 @@ class DibiProfiler extends DibiObject implements IDibiProfiler, IDebugPanel
|
|||||||
$connection->getConfig('driver') . '/' . $connection->getConfig('name')
|
$connection->getConfig('driver') . '/' . $connection->getConfig('name')
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->explainQuery && $event === self::SELECT) {
|
|
||||||
$tmpSql = dibi::$sql;
|
|
||||||
try {
|
|
||||||
$ticket[5] = dibi::dump($connection->setProfiler(NULL)->nativeQuery('EXPLAIN ' . $sql), TRUE);
|
|
||||||
} catch (DibiException $e) {}
|
|
||||||
$connection->setProfiler($this);
|
|
||||||
dibi::$sql = $tmpSql;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->useFirebug && !headers_sent()) {
|
if ($this->useFirebug && !headers_sent()) {
|
||||||
header('X-Wf-Protocol-dibi: http://meta.wildfirehq.org/Protocol/JsonStream/0.2');
|
header('X-Wf-Protocol-dibi: http://meta.wildfirehq.org/Protocol/JsonStream/0.2');
|
||||||
header('X-Wf-dibi-Plugin-1: http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.2.0');
|
header('X-Wf-dibi-Plugin-1: http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.2.0');
|
||||||
@@ -282,8 +273,17 @@ class DibiProfiler extends DibiObject implements IDibiProfiler, IDebugPanel
|
|||||||
";
|
";
|
||||||
$i = 0; $classes = array('class="nette-alt"', '');
|
$i = 0; $classes = array('class="nette-alt"', '');
|
||||||
foreach (self::$tickets as $ticket) {
|
foreach (self::$tickets as $ticket) {
|
||||||
list($connection, $event, $sql, $time, $count, $explain) = $ticket;
|
list($connection, $event, $sql, $time, $count) = $ticket;
|
||||||
if (!($event & self::QUERY)) continue;
|
if (!($event & self::QUERY)) continue;
|
||||||
|
|
||||||
|
$explain = NULL; // EXPLAIN is called here to work SELECT FOUND_ROWS()
|
||||||
|
if ($this->explainQuery && $event === self::SELECT) {
|
||||||
|
try {
|
||||||
|
$explain = dibi::dump($connection->setProfiler(NULL)->nativeQuery('EXPLAIN ' . $sql), TRUE);
|
||||||
|
} catch (DibiException $e) {}
|
||||||
|
$connection->setProfiler($this);
|
||||||
|
}
|
||||||
|
|
||||||
$content .= "
|
$content .= "
|
||||||
<tr {$classes[++$i%2]}>
|
<tr {$classes[++$i%2]}>
|
||||||
<td>" . sprintf('%0.3f', $time * 1000) . ($explain ? "
|
<td>" . sprintf('%0.3f', $time * 1000) . ($explain ? "
|
||||||
|
Reference in New Issue
Block a user