當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。