Skip to content
Browse files

Database\ConnectionPanel: explain SQL command can be altered

  • Loading branch information...
1 parent a17f891 commit 1e2e20f9f278e23eb616d3129039963eb41d92c3 @dg dg committed Jan 23, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 Nette/Database/Diagnostics/ConnectionPanel.php
View
7 Nette/Database/Diagnostics/ConnectionPanel.php
@@ -36,7 +36,7 @@ class ConnectionPanel extends Nette\Object implements Nette\Diagnostics\IBarPane
/** @var string */
public $name;
- /** @var bool explain queries? */
+ /** @var bool|string explain queries? */
public $explain = TRUE;
/** @var bool */
@@ -96,9 +96,10 @@ public function getPanel()
list($sql, $params, $time, $rows, $connection, $source) = $query;
$explain = NULL; // EXPLAIN is called here to work SELECT FOUND_ROWS()
- if ($this->explain && preg_match('#\s*SELECT\s#iA', $sql)) {
+ if ($this->explain && preg_match('#\s*\(?\s*SELECT\s#iA', $sql)) {
try {
- $explain = $connection->queryArgs('EXPLAIN ' . $sql, $params)->fetchAll();
+ $cmd = is_string($this->explain) ? $this->explain : 'EXPLAIN';
+ $explain = $connection->queryArgs("$cmd $sql", $params)->fetchAll();
} catch (\PDOException $e) {}
}

0 comments on commit 1e2e20f

Please sign in to comment.
Something went wrong with that request. Please try again.