當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Gdn_DataSet::PDOStatement方法代碼示例

本文整理匯總了PHP中Gdn_DataSet::PDOStatement方法的典型用法代碼示例。如果您正苦於以下問題:PHP Gdn_DataSet::PDOStatement方法的具體用法?PHP Gdn_DataSet::PDOStatement怎麽用?PHP Gdn_DataSet::PDOStatement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Gdn_DataSet的用法示例。


在下文中一共展示了Gdn_DataSet::PDOStatement方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Query

 /**
  * Executes a string of SQL. Returns a @@DataSet object. This is an override
  * method because of SQL Server's lack of a LIMIT clause.
  *
  * @param string $Sql A string of SQL to be executed.
  */
 public function Query($Sql)
 {
     if ($Sql == '') {
         trigger_error(ErrorMessage('Database was queried with an empty string.', $this->ClassName, 'Query'), E_USER_ERROR);
     }
     // Make sure that we don't need to wipe out the pdo statement (and related named parameters)
     if ($this->_PDOStatement !== FALSE && $Sql != $this->_PDOStatement->queryString) {
         // echo '<div>Existing: '.$this->_PDOStatement->queryString.'</div>';
         // echo '<div>New: '.$Sql.'</div>';
         $this->_ResetPDOStatement();
     }
     // Save the query for debugging
     $this->Queries[] = $Sql;
     // Start the Query Timer
     $TimeStart = list($sm, $ss) = explode(' ', microtime());
     // Run the Query
     if (count($this->_NamedParameters) > 0) {
         if ($this->_PDOStatement === FALSE) {
             $this->_PDOStatement = $this->Connection()->prepare($Sql);
         }
         $this->_PDOStatement->execute($this->_NamedParameters);
     } else {
         $this->_PDOStatement = $this->Connection()->query($Sql);
     }
     if ($this->_PDOStatement === FALSE) {
         $Error = $this->Connection()->errorInfo();
         trigger_error(ErrorMessage($Error[2], $this->ClassName, 'Query', $Sql), E_USER_ERROR);
     }
     // Aggregate the query times
     $TimeEnd = list($em, $es) = explode(' ', microtime());
     $this->_ExecutionTime += $em + $es - ($sm + $ss);
     $this->QueryTimes[] = $em + $es - ($sm + $ss);
     // Did this query modify data in any way?
     if (preg_match('/^\\s*"?(insert|update|delete|replace|create|drop|load data|copy|alter|grant|revoke|lock|unlock)\\s+/i', $Sql)) {
         return TRUE;
     }
     // Dispose of unneeded rows
     $i = 0;
     while ($i < $this->_Offset && $this->_PDOStatement->fetch()) {
         ++$i;
     }
     // Set the limit back to 0
     $this->_Offset = 0;
     // Create a DataSet to manage the resultset
     $ResultSet = new Gdn_DataSet();
     $ResultSet->Connection =& $this->_Connection;
     // Not using $this->Connection() because we know for a fact that the connection was created a few lines above.
     $ResultSet->PDOStatement($this->_PDOStatement);
     return $ResultSet;
 }
開發者ID:Aetasiric,項目名稱:Garden,代碼行數:56,代碼來源:class.mssql.driver.php


注:本文中的Gdn_DataSet::PDOStatement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。