resource = $resource; $this->generatedValue = $generatedValue; $this->rowCount = $rowCount; return $this; } /** * @return null */ public function buffer() { return null; } /** * @return bool|null */ public function isBuffered() { return false; } /** * Get resource * * @return mixed */ public function getResource() { return $this->resource; } /** * Get the data * @return array */ public function current() { if ($this->currentComplete) { return $this->currentData; } $this->currentData = $this->resource->fetch(\PDO::FETCH_ASSOC); $this->currentComplete = true; return $this->currentData; } /** * Next * * @return mixed */ public function next() { $this->currentData = $this->resource->fetch(\PDO::FETCH_ASSOC); $this->currentComplete = true; $this->position++; return $this->currentData; } /** * Key * * @return mixed */ public function key() { return $this->position; } /** * @throws Exception\RuntimeException * @return void */ public function rewind() { if ($this->statementMode == self::STATEMENT_MODE_FORWARD && $this->position > 0) { throw new Exception\RuntimeException( 'This result is a forward only result set, calling rewind() after moving forward is not supported' ); } $this->currentData = $this->resource->fetch(\PDO::FETCH_ASSOC); $this->currentComplete = true; $this->position = 0; } /** * Valid * * @return bool */ public function valid() { return ($this->currentData !== false); } /** * Count * * @return int */ public function count() { if (is_int($this->rowCount)) { return $this->rowCount; } if ($this->rowCount instanceof \Closure) { $this->rowCount = (int) call_user_func($this->rowCount); } else { $this->rowCount = (int) $this->resource->rowCount(); } return $this->rowCount; } /** * @return int */ public function getFieldCount() { return $this->resource->columnCount(); } /** * Is query result * * @return bool */ public function isQueryResult() { return ($this->resource->columnCount() > 0); } /** * Get affected rows * * @return int */ public function getAffectedRows() { return $this->resource->rowCount(); } /** * @return mixed|null */ public function getGeneratedValue() { return $this->generatedValue; } }