/** * 获得一条查询结果一列的一个值,没有数据则返回false * @param string $sql 要执行的SQL指令 * @return 获得一条查询结果一列的一个值,没有数据则返回false * @access public */ public function getOne($sql) { $this->query($sql); $result = $this->PDOStatement->fetchColumn(); $this->PDOStatement = null; return $result; }
/** * 获取数据库数据 * * @param string $sSQL * @param array $aParam * @param int $iType * 1-column, 2-row, 3-list * @return array/string */ protected function _getDBData($sSQL, $aParam, $iType, $bStrictMaster) { $this->_exectue($sSQL, $aParam, $bStrictMaster, false); $this->_oSth->setFetchMode(PDO::FETCH_ASSOC); switch ($iType) { case 1: $mData = $this->_oSth->fetchColumn(); break; case 2: $mData = $this->_oSth->fetch(); break; case 3: $mData = $this->_oSth->fetchAll(); break; } return $mData; }
/** * Fetch the first field of the first row * * @param object $result The result object. * @param integer $key The index to use. * @return string The value returned in the query. */ protected function _fetchField($result, $key = 0) { $return = $result->fetchColumn((int) $key); $result = null; return $return; }