db = $db; if ( $result instanceof ResultWrapper ) { $this->result = $result->result; } else { $this->result = $result; } } public function numRows() { return $this->getDB()->numRows( $this ); } public function fetchObject() { return $this->getDB()->fetchObject( $this ); } public function fetchRow() { return $this->getDB()->fetchRow( $this ); } public function seek( $pos ) { $this->getDB()->dataSeek( $this, $pos ); $this->pos = $pos; } public function free() { $this->db = null; $this->result = null; } function rewind() { if ( $this->numRows() ) { $this->getDB()->dataSeek( $this, 0 ); } $this->pos = 0; $this->currentRow = null; } function current() { if ( $this->currentRow === null ) { $this->currentRow = $this->fetchObject(); } return $this->currentRow; } function key() { return $this->pos; } function next() { $this->pos++; $this->currentRow = $this->fetchObject(); return $this->currentRow; } function valid() { return $this->current() !== false; } /** * @return IDatabase * @throws RuntimeException */ private function getDB() { if ( !$this->db ) { throw new RuntimeException( static::class . ' needs a DB handle for iteration.' ); } return $this->db; } } /** * @deprecated since 1.29 */ class_alias( ResultWrapper::class, 'ResultWrapper' );