Db::free PHP Method

free() public method

释放查询结果
public free ( )
    public function free()
    {
        // @mysql_free_result($this->queryID);
        $this->queryID = 0;
    }

Usage Example

 /**
  * Select query and return one value result.
  *
  * @param string $sTable
  * @param string $sField Default: NULL
  * @param string $sId Default: NULL
  * @param string $sWhat Default: '*'
  * @param string $sOptions Default: NULL
  * @return mixed (string | object | boolean) SQL query on success (returns strong or object value) or throw PDOException on failure (returns a false boolean).
  *
  */
 public function getOne($sTable, $sField = null, $sId = null, $sWhat = '*', $sOptions = null)
 {
     try {
         $bIsWhere = isset($sField, $sId);
         $this->_sSql = 'SELECT ' . $sWhat . ' FROM' . Db::prefix($sTable);
         if ($bIsWhere) {
             $this->_sSql .= "WHERE {$sField} = :id ";
         }
         if (!empty($sOptions)) {
             $this->_sSql .= " {$sOptions} ";
         }
         $this->_sSql .= 'LIMIT 0,1';
         // Get only one column
         $rStmt = Db::getInstance()->prepare($this->_sSql);
         if ($bIsWhere) {
             $rStmt->bindParam(':id', $sId);
         }
         $rStmt->execute();
         $mRow = $rStmt->fetch(\PDO::FETCH_OBJ);
         Db::free($rStmt);
         return $mRow;
     } catch (Exception $oE) {
         $this->_aErrors[] = $oE->getMessage();
     }
 }