当前位置: 首页>>代码示例>>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;未经允许,请勿转载。