/** * Get the first record from a result set. * * This method will also close the underlying statement cursor. * * @return array|object */ public function first() { foreach ($this as $result) { if ($this->_statement && !$this->_useBuffering) { $this->_statement->closeCursor(); } return $result; } }
/** * Returns the first result in this set and blocks the set so that no other * results can be fetched. * * When using serialized results, the index will be incremented past the * end of the results simulating the behavior when the result set is backed * by a statement. * * @return array|object */ public function first() { if (isset($this->_results[0])) { return $this->_results[0]; } if ($this->valid()) { if ($this->_statement) { $this->_statement->closeCursor(); } if (!$this->_statement && $this->_results) { $this->_index = count($this->_results); } return $this->_current; } return null; }