当前位置: 首页>>代码示例>>PHP>>正文


PHP dibi::sql方法代码示例

本文整理汇总了PHP中dibi::sql方法的典型用法代码示例。如果您正苦于以下问题:PHP dibi::sql方法的具体用法?PHP dibi::sql怎么用?PHP dibi::sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dibi的用法示例。


在下文中一共展示了dibi::sql方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct(DibiConnection $connection, $type, $sql = NULL)
 {
     $this->connection = $connection;
     $this->type = $type;
     $this->sql = trim($sql);
     $this->time = -microtime(TRUE);
     if ($type === self::QUERY && preg_match('#\\(?\\s*(SELECT|UPDATE|INSERT|DELETE)#iA', $this->sql, $matches)) {
         static $types = array('SELECT' => self::SELECT, 'UPDATE' => self::UPDATE, 'INSERT' => self::INSERT, 'DELETE' => self::DELETE);
         $this->type = $types[strtoupper($matches[1])];
     }
     $rc = new ReflectionClass('dibi');
     $dibiDir = dirname($rc->getFileName()) . DIRECTORY_SEPARATOR;
     foreach (debug_backtrace(FALSE) as $row) {
         if (isset($row['file']) && is_file($row['file']) && strpos($row['file'], $dibiDir) !== 0) {
             $this->source = array($row['file'], (int) $row['line']);
             break;
         }
     }
     dibi::$elapsedTime = FALSE;
     dibi::$numOfQueries++;
     dibi::$sql = $sql;
 }
开发者ID:Scrik,项目名称:Need-For-Speed-World-Statistics-Website,代码行数:22,代码来源:DibiEvent.php

示例2: nativeQuery

 /**
  * Executes the SQL query.
  * @param  string           SQL statement.
  * @return DibiResult|int   result set object (if any)
  * @throws DibiException
  */
 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::$sql = $sql;
     if ($res = $this->driver->query($sql)) {
         // intentionally =
         $res = new DibiResult($res, $this->config);
     } else {
         $res = $this->driver->getAffectedRows();
     }
     if (isset($ticket)) {
         $this->profiler->after($ticket, $res);
     }
     return $res;
 }
开发者ID:vrana,项目名称:dibi,代码行数:29,代码来源:DibiConnection.php

示例3: nativeQuery

 /**
  * Executes the SQL query.
  * @param  string           SQL statement.
  * @return Result|int   result set object (if any)
  * @throws Exception
  */
 public final function nativeQuery($sql)
 {
     $this->connected || $this->connect();
     \dibi::$sql = $sql;
     $event = $this->onEvent ? new Event($this, Event::QUERY, $sql) : NULL;
     try {
         $res = $this->driver->query($sql);
     } catch (Exception $e) {
         $event && $this->onEvent($event->done($e));
         throw $e;
     }
     if ($res) {
         $res = $this->createResultSet($res);
     } else {
         $res = $this->driver->getAffectedRows();
     }
     $event && $this->onEvent($event->done($res));
     return $res;
 }
开发者ID:janlanger,项目名称:dibi,代码行数:25,代码来源:Connection.php

示例4: nativeQuery

 /**
  * Executes the SQL query.
  * @param  string           SQL statement.
  * @return DibiResult|int   result set object (if any)
  * @throws DibiException
  */
 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);
     }
     // TODO: move to profiler?
     dibi::$numOfQueries++;
     dibi::$sql = $sql;
     dibi::$elapsedTime = FALSE;
     $time = -microtime(TRUE);
     if ($res = $this->driver->query($sql)) {
         // intentionally =
         $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;
 }
开发者ID:vlki,项目名称:dibi,代码行数:36,代码来源:DibiConnection.php

示例5: after

 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) {
                 $tmpSql = dibi::$sql;
                 try {
                     $ticket[5] = dibi::dump($connection->setProfiler(NULL)->nativeQuery('EXPLAIN ' . $sql), TRUE);
                 } catch (DibiException $e) {
                 }
                 $connection->setProfiler($this);
                 dibi::$sql = $tmpSql;
             }
             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}|\\");
                 }
                 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");
         }
     }
 }
开发者ID:jaroslavlibal,项目名称:MDW,代码行数:47,代码来源:dibi.min.php

示例6:

translateArgs($args){$this->connected||$this->connect();return$this->translator->translate($args);}final
function
nativeQuery($sql){$this->connected||$this->connect();if($this->profiler!==NULL){$event=IDibiProfiler::QUERY;if(preg_match('#\s*(SELECT|UPDATE|INSERT|DELETE)#iA',$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::$sql=$sql;if($res=$this->driver->query($sql)){$res=$this->createResultSet($res);}else{$res=$this->driver->getAffectedRows();}if(isset($ticket)){$this->profiler->after($ticket,$res);}return$res;}function
开发者ID:nosko,项目名称:socialSearch,代码行数:3,代码来源:dibi.min.php

示例7: 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;
 }
开发者ID:laiello,项目名称:webuntucms,代码行数:25,代码来源:DibiConnection.php


注:本文中的dibi::sql方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。