/** * alias to queryFirst * @param $sql * @return FALSE */ public function getRow($sql) { assert($this->_handle); return DBMysqlNamespace::getRow($this->_handle, $sql); }
/** * 根据where条件获取记录 * @param string|array $where where条件 * string e.g. string 'id=3 and create_at<2222222 or type in (2,3)' * array e.g. array('id' => 3, 'type' => 2) * @param string $fields 选择的字段 'id,type,create_at' * @param string $orderBy 排序条件 e.g. 'id desc' * @return type */ public function getRow($where, $selectField = '*', $orderBy = '') { if (empty($where) || empty($selectField)) { return array(); } if (strstr($selectField, 'count') || strstr($selectField, 'sum')) { $sql = $this->sqlBuilder->createSelectSql($selectField, $where); } else { $sql = $this->sqlBuilder->createSelectSql($selectField, $where, $orderBy, 1); } self::addSqlHistory($sql); return DBMysqlNamespace::getRow($this->getSlaveDb(), $sql); }