connection = $connection; $this->result = $result; $this->cursorClosed = false; } function rows() { return $this->result->rowCount(); } function next() { $this->resultArray = $this->result->fetch(); if ($this->resultArray) { return true; } else { $this->result->closeCursor(); $this->cursorClosed = true; return false; } } function get($position) { if (is_int($position)) --$position; // $position starts with 1, array index with 0 return $this->resultArray[$position]; } function getArray() { return $this->result->fetch(); } function getObject() { return $this->result->fetch(PDO::FETCH_OBJ); } function __destruct() { if (!cursorClosed) $this->result->closeCursor(); unset($this->resultArray); unset($this->result); unset($this->connection); } } ?>