diff --git a/dibi/dibi.php b/dibi/dibi.php
index dd70f140..bdfef492 100644
--- a/dibi/dibi.php
+++ b/dibi/dibi.php
@@ -705,7 +705,7 @@ class dibi
$sql = wordwrap($sql, 100);
$sql = htmlSpecialChars($sql);
- $sql = preg_replace("#\n{2,}#", "\n", $sql);
+ $sql = preg_replace("#([ \t]*\r?\n){2,}#", "\n", $sql);
// syntax highlight
$sql = preg_replace_callback("#(/\\*.+?\\*/)|(\\*\\*.+?\\*\\*)|(?<=[\\s,(])($keywords1)(?=[\\s,)])|(?<=[\\s,(=])($keywords2)(?=[\\s,)=])#is", array('dibi', 'highlightCallback'), $sql);
diff --git a/dibi/libs/DibiException.php b/dibi/libs/DibiException.php
index 0e6491a9..5da60dff 100644
--- a/dibi/libs/DibiException.php
+++ b/dibi/libs/DibiException.php
@@ -67,10 +67,10 @@ class DibiException extends Exception implements /*Nette\*/IDebugPanel
* Returns HTML code for custom tab.
* @return mixed
*/
- public function getTab()
- {
+ public function getTab()
+ {
return 'SQL';
- }
+ }
diff --git a/dibi/libs/DibiProfiler.php b/dibi/libs/DibiProfiler.php
index 9635c96c..14a97ec0 100644
--- a/dibi/libs/DibiProfiler.php
+++ b/dibi/libs/DibiProfiler.php
@@ -89,7 +89,7 @@ class DibiProfiler extends DibiObject implements IDibiProfiler, /*Nette\*/IDebug
{
if ($event & self::QUERY) dibi::$numOfQueries++;
dibi::$elapsedTime = FALSE;
- self::$tickets[] = array($connection, $event, trim($sql), -microtime(TRUE), NULL);
+ self::$tickets[] = array($connection, $event, trim($sql), -microtime(TRUE), NULL, NULL);
end(self::$tickets);
return key(self::$tickets);
}
@@ -132,6 +132,13 @@ class DibiProfiler extends DibiObject implements IDibiProfiler, /*Nette\*/IDebug
$connection->getConfig('driver') . '/' . $connection->getConfig('name')
);
+ if ($event === self::SELECT) {
+ try {
+ $ticket[5] = dibi::dump($connection->setProfiler(NULL)->nativeQuery('EXPLAIN ' . $sql), TRUE);
+ } catch (DibiException $e) {}
+ $connection->setProfiler($this);
+ }
+
if ($this->useFirebug && !headers_sent()) {
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');
@@ -217,11 +224,11 @@ class DibiProfiler extends DibiObject implements IDibiProfiler, /*Nette\*/IDebug
* Returns HTML code for custom tab.
* @return mixed
*/
- public function getTab()
- {
+ public function getTab()
+ {
return ''
. dibi::$numOfQueries . ' queries';
- }
+ }
@@ -233,14 +240,34 @@ class DibiProfiler extends DibiObject implements IDibiProfiler, /*Nette\*/IDebug
{
if (!dibi::$numOfQueries) return;
- $content = '
$row[0] | $row[1] | $row[2] | $row[3] |
---|---|---|---|
$row[0] | $row[1] | $row[2] | $row[3] |
Time | SQL Statement | Rows | Connection | +
---|---|---|---|
" . sprintf('%0.3f', $time * 1000) . "
+ explain ► |
+ " . dibi::dump(strlen($sql) > self::$maxLength ? substr($sql, 0, self::$maxLength) . '...' : $sql, TRUE) . "
+ {$explain} |
+ {$count} | +" . htmlSpecialChars($connection->getConfig('driver') . '/' . $connection->getConfig('name')) . " | +
':'► ');}}?>
-
+_netteDumpCb2($m){return"$m[1]$m[2]($m[3]) ".($m[3]<7?'▼ ':'► ');}}?>
+
Dumped variables
@@ -518,9 +519,7 @@ preg_replace_callback('#(|\s+)?(.*)\((\d+)\) #','_