1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-05 05:37:39 +02:00

DibiNettePanel: explain SQL command can be altered

This commit is contained in:
David Grudl
2012-01-19 00:26:43 +01:00
parent 5d41128752
commit 70fd2368aa

View File

@@ -42,7 +42,7 @@ class DibiNettePanel extends DibiObject implements IBarPanel
public function __construct($explain = TRUE, $filter = NULL) public function __construct($explain = TRUE, $filter = NULL)
{ {
$this->filter = $filter ? (int) $filter : DibiEvent::QUERY; $this->filter = $filter ? (int) $filter : DibiEvent::QUERY;
$this->explain = (bool) $explain; $this->explain = $explain;
} }
@@ -123,7 +123,8 @@ class DibiNettePanel extends DibiObject implements IBarPanel
try { try {
$backup = array($event->connection->onEvent, dibi::$numOfQueries, dibi::$totalTime); $backup = array($event->connection->onEvent, dibi::$numOfQueries, dibi::$totalTime);
$event->connection->onEvent = NULL; $event->connection->onEvent = NULL;
$explain = dibi::dump($event->connection->nativeQuery('EXPLAIN ' . $event->sql), TRUE); $cmd = is_string($this->explain) ? $this->explain : 'EXPLAIN';
$explain = dibi::dump($event->connection->nativeQuery("$cmd $event->sql"), TRUE);
} catch (DibiException $e) {} } catch (DibiException $e) {}
list($event->connection->onEvent, dibi::$numOfQueries, dibi::$totalTime) = $backup; list($event->connection->onEvent, dibi::$numOfQueries, dibi::$totalTime) = $backup;
} }