mirror of
https://github.com/dg/dibi.git
synced 2025-08-05 05:37:39 +02:00
- requires FirePHP 0.2
- improved DibiFluent
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user