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


PHP WT_DB::logQuery方法代码示例

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


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

示例1: execute

 /**
  * Execute a query
  *
  * @param array $bind_variables
  *
  * @return WT_DBStatement
  * @throws Exception
  */
 public function execute($bind_variables = array())
 {
     if ($this->executed) {
         throw new Exception('WT_DBStatement::execute() called twice.');
     }
     // Turn booleans into integers.  Otherwise MySQL’s strict mode can get upset.
     foreach ($bind_variables as &$bind_variable) {
         if ($bind_variable === false) {
             // Otherwise true=>'1' and false=>''
             $bind_variable = 0;
         }
     }
     $start = microtime(true);
     $this->pdo_statement->execute($bind_variables);
     $end = microtime(true);
     // If it was a SELECT statement, we cannot run it again.
     $this->executed = strpos($this->pdo_statement->queryString, 'SELECT') === 0;
     WT_DB::logQuery($this->pdo_statement->queryString, $this->pdo_statement->rowCount(), $end - $start, $bind_variables);
     return $this;
 }
开发者ID:jacoline,项目名称:webtrees,代码行数:28,代码来源:DBStatement.php

示例2: __call

 public function __call($function, $params)
 {
     switch ($function) {
         case 'closeCursor':
             $this->executed = false;
             // no break;
         // no break;
         case 'bindColumn':
         case 'bindParam':
         case 'bindValue':
             // TODO: bind variables need to be stored in $this->bind_variables so we can log them
         // TODO: bind variables need to be stored in $this->bind_variables so we can log them
         case 'setAttribute':
         case 'setFetchMode':
             // Functions that return no values become fluent
             call_user_func_array(array($this->pdostatement, $function), $params);
             return $this;
         case 'execute':
             if ($this->executed) {
                 trigger_error('WT_DBStatement::execute() called twice.', E_USER_ERROR);
             } else {
                 if ($params) {
                     $this->bind_variables = $params[0];
                     foreach ($params[0] as &$param) {
                         if ($param === false) {
                             // For consistency, otherwise true=>'1' and false=>''
                             $param = 0;
                         }
                     }
                 }
                 $start = microtime(true);
                 call_user_func_array(array($this->pdostatement, $function), $params);
                 $end = microtime(true);
                 $this->executed = !preg_match('/^(insert|delete|update|create|alter) /i', $this->pdostatement->queryString);
                 WT_DB::logQuery($this->pdostatement->queryString, $this->pdostatement->rowCount(), $end - $start, $this->bind_variables);
                 return $this;
             }
         case 'fetch':
         case 'fetchColumn':
         case 'fetchObject':
         case 'fetchAll':
             // Automatically execute the query
             if (!$this->executed) {
                 $this->execute();
                 $this->executed = true;
             }
             // no break;
         // no break;
         default:
             return call_user_func_array(array($this->pdostatement, $function), $params);
     }
 }
开发者ID:brambravo,项目名称:webtrees,代码行数:52,代码来源:DBStatement.php


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