diff --git a/dibi/libs/DibiFluent.php b/dibi/libs/DibiFluent.php index 30eb8e9d..fedc1abd 100644 --- a/dibi/libs/DibiFluent.php +++ b/dibi/libs/DibiFluent.php @@ -40,6 +40,8 @@ class DibiFluent extends DibiObject /** @var array */ public static $modifiers = array( + 'SELECT' => '%n', + 'IN' => '%l', 'VALUES' => '%l', 'SET' => '%a', 'WHERE' => '%and', @@ -120,8 +122,13 @@ class DibiFluent extends DibiObject } elseif (is_string($arg) && preg_match('#^[a-z][a-z0-9_.]*$#i', $arg)) { // identifier $args = array('%n', $arg); - } elseif (is_array($arg) && is_string(key($arg))) { // associative array - $args = array(isset(self::$modifiers[$clause]) ? self::$modifiers[$clause] : '%a', $arg); + } elseif (is_array($arg)) { // any array + if (isset(self::$modifiers[$clause])) { + $args = array(self::$modifiers[$clause], $arg); + + } elseif (is_string(key($arg))) { // associative array + $args = array('%a', $arg); + } } } diff --git a/dibi/libs/DibiProfiler.php b/dibi/libs/DibiProfiler.php index 0d4d6cc5..7761c4b5 100644 --- a/dibi/libs/DibiProfiler.php +++ b/dibi/libs/DibiProfiler.php @@ -111,17 +111,29 @@ class DibiProfiler extends DibiObject implements IDibiProfiler if ($this->useFirebug) { self::$table[] = array( sprintf('%0.3f', dibi::$elapsedTime * 1000), - trim(preg_replace('#\s+#', ' ', $sql)), + trim($sql), $res instanceof DibiResult ? count($res) : '-', $connection->getConfig('driver') . '/' . $connection->getConfig('name') ); - $caption = 'dibi profiler (' . dibi::$numOfQueries . ' SQL queries took ' . sprintf('%0.3f', dibi::$totalTime * 1000) . ' ms)'; - $payload['FirePHP.Firebug.Console'][] = array('TABLE', array($caption, self::$table)); + 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-Structure-1: http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); + + $payload = array( + array( + 'Type' => 'TABLE', + 'Label' => 'dibi profiler (' . dibi::$numOfQueries . ' SQL queries took ' . sprintf('%0.3f', dibi::$totalTime * 1000) . ' ms)', + ), + self::$table, + ); $payload = function_exists('json_encode') ? json_encode($payload) : self::json_encode($payload); - foreach (str_split($payload, 4998) as $num => $s) { - header('X-FirePHP-Data-' . str_pad(++$num, 12, '0', STR_PAD_LEFT) . ': ' . $s); + foreach (str_split($payload, 4990) as $num => $s) { + $num++; + header("X-Wf-dibi-1-1-$num: |$s|\\"); // protocol-, structure-, plugin-, message-index } + header("X-Wf-dibi-1-1-$num: |$s|"); + header("X-Wf-dibi-Index: $num"); } if ($this->file) {