/** * * {@inheritDoc} */ public function fetchValue(array $params = array()) { $param_keys_2_exclude = array('limit_offset', 'limit_size'); $query_obj = $this->_buildFetchQueryObjectFromParams($params, $param_keys_2_exclude); $query_obj->limit(1); $sql = $query_obj->__toString(); $params_2_bind_2_sql = $query_obj->getBindValues(); $result = $this->_db_connector->dbFetchValue($sql, $params_2_bind_2_sql); //need to issue a second query to get the number of matching rows $params['cols'] = array(' COUNT(*) AS num_rows'); $query_obj_4_num_matching_rows = $this->_buildFetchQueryObjectFromParams($params, $param_keys_2_exclude); $sql = $query_obj_4_num_matching_rows->__toString(); $params_2_bind_2_sql = $query_obj_4_num_matching_rows->getBindValues(); $num_matching_rows = $this->_db_connector->dbFetchOne($sql, $params_2_bind_2_sql); //return null if there wasn't any matching row return intval($num_matching_rows['num_rows']) > 0 ? $result : null; }