本文整理匯總了PHP中dibi::elapsedTime方法的典型用法代碼示例。如果您正苦於以下問題:PHP dibi::elapsedTime方法的具體用法?PHP dibi::elapsedTime怎麽用?PHP dibi::elapsedTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dibi
的用法示例。
在下文中一共展示了dibi::elapsedTime方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: done
public function done($result = NULL)
{
$this->result = $result;
try {
$this->count = $result instanceof DibiResult ? count($result) : NULL;
} catch (DibiException $e) {
$this->count = NULL;
}
$this->time += microtime(TRUE);
dibi::$elapsedTime = $this->time;
dibi::$totalTime += $this->time;
return $this;
}
示例2: after
/**
* After event notification.
* @param int
* @param DibiResult
* @return void
*/
public function after($ticket, $res = NULL)
{
if (!isset(self::$tickets[$ticket])) {
throw new InvalidArgumentException('Bad ticket number.');
}
$ticket =& self::$tickets[$ticket];
$ticket[3] += microtime(TRUE);
list($connection, $event, $sql, $time) = $ticket;
dibi::$elapsedTime = $time;
dibi::$totalTime += $time;
if (($event & $this->filter) === 0) {
return;
}
if ($event & self::QUERY) {
try {
$ticket[4] = $count = $res instanceof DibiResult ? count($res) : '-';
} catch (Exception $e) {
$count = '?';
}
if (count(self::$fireTable) < self::$maxQueries) {
self::$fireTable[] = array(sprintf('%0.3f', $time * 1000), strlen($sql) > self::$maxLength ? substr($sql, 0, self::$maxLength) . '...' : $sql, $count, $connection->getConfig('driver') . '/' . $connection->getConfig('name'));
if ($this->explainQuery && $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');
header('X-Wf-dibi-Structure-1: http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1');
$payload = json_encode(array(array('Type' => 'TABLE', 'Label' => 'dibi profiler (' . dibi::$numOfQueries . ' SQL queries took ' . sprintf('%0.3f', dibi::$totalTime * 1000) . ' ms)'), self::$fireTable));
foreach (str_split($payload, 4990) as $num => $s) {
$num++;
header("X-Wf-dibi-1-1-d{$num}: |{$s}|\\");
// protocol-, structure-, plugin-, message-index
}
header("X-Wf-dibi-1-1-d{$num}: |{$s}|");
}
}
if ($this->file) {
$this->writeFile("OK: " . $sql . ($res instanceof DibiResult ? ";\n-- rows: " . $count : '') . "\n-- takes: " . sprintf('%0.3f', $time * 1000) . ' ms' . "\n-- driver: " . $connection->getConfig('driver') . '/' . $connection->getConfig('name') . "\n-- " . date('Y-m-d H:i:s') . "\n\n");
}
}
}
示例3: nativeQuery
public final function nativeQuery($sql)
{
$this->connect();
if ($this->profiler !== NULL) {
$event = IDibiProfiler::QUERY;
if (preg_match('#\\s*(SELECT|UPDATE|INSERT|DELETE)#i', $sql, $matches)) {
static $events = array('SELECT' => IDibiProfiler::SELECT, 'UPDATE' => IDibiProfiler::UPDATE, 'INSERT' => IDibiProfiler::INSERT, 'DELETE' => IDibiProfiler::DELETE);
$event = $events[strtoupper($matches[1])];
}
$ticket = $this->profiler->before($this, $event, $sql);
}
dibi::$numOfQueries++;
dibi::$sql = $sql;
dibi::$elapsedTime = FALSE;
$time = -microtime(TRUE);
if ($res = $this->driver->query($sql)) {
$res = new DibiResult($res, $this->config);
} else {
$res = $this->driver->getAffectedRows();
}
$time += microtime(TRUE);
dibi::$elapsedTime = $time;
dibi::$totalTime += $time;
if (isset($ticket)) {
$this->profiler->after($ticket, $res);
}
return $res;
}
示例4: nativeQuery
/**
* Executes the SQL query.
*
* @param string SQL statement.
* @return DibiResult|NULL result set object (if any)
* @throws DibiException
*/
public final function nativeQuery($sql)
{
$this->connect();
dibi::$numOfQueries++;
dibi::$sql = $sql;
dibi::$elapsedTime = FALSE;
$time = -microtime(TRUE);
dibi::notify($this, 'beforeQuery', $sql);
if ($res = $this->driver->query($sql)) {
// intentionally =
$res = new DibiResult($res, $this->config);
}
$time += microtime(TRUE);
dibi::$elapsedTime = $time;
dibi::$totalTime += $time;
dibi::notify($this, 'afterQuery', $res);
return $res;
}