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 = '

SQL queries: ' . dibi::$numOfQueries . (dibi::$totalTime === NULL ? '' : ', elapsed time: ' . sprintf('%0.3f', dibi::$totalTime * 1000) . ' ms') . '

'; - $content .= ''; - foreach (self::$table as $i => $row) { - if ($i === 0) { - $content .= ""; - } else { - $content .= ""; - } + $content = " +

SQL queries: " . dibi::$numOfQueries . (dibi::$totalTime === NULL ? '' : ', elapsed time: ' . sprintf('%0.3f', dibi::$totalTime * 1000) . ' ms') . "

+ + + +
$row[0]$row[1]$row[2]$row[3]
$row[0]$row[1]$row[2]$row[3]
+ + + +"; + $i = 0; $classes = array('class="nette-alt"', ''); + foreach (self::$tickets as $ticket) { + list($connection, $event, $sql, $time, $count, $explain) = $ticket; + if (!($event & self::QUERY)) continue; + $content .= " + + + + + + +"; } $content .= '
TimeSQL StatementRowsConnection
" . 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')) . "
'; return $content; diff --git a/examples/Nette/Debug.php b/examples/Nette/Debug.php index 3cb01fda..421f60fa 100644 --- a/examples/Nette/Debug.php +++ b/examples/Nette/Debug.php @@ -72,40 +72,54 @@ as$panel){$panels[]=array('id'=>preg_replace('#[^a-z0-9]+#i','-',$panel->getId() - + -
+$panel):?> +
+
+
+
+ ¤ + × +
+
+
+ +
    @@ -122,23 +136,10 @@ trim($panel['tab'])?>',trim($panel['tab']),'
';end
-$panel):?> -
-
-
-
- ¤ - × -
-
-
- - - kB return;case'dumps:tab':if(!Debug::$dumps)return;?>variables $m[2]($m[3]) ".($m[3]<7?' ':' ');}}?> - +_netteDumpCb2($m){return"$m[1]$m[2]($m[3]) ".($m[3]<7?' ':' ');}}?> +

Dumped variables

@@ -518,9 +519,7 @@ preg_replace_callback('#(
|\s+)?(.*)\((\d+)\) #','_
 	
 
 
-
- errors