valid()) { $keys = array_keys($this->current()); $out = $this->current()[array_shift($keys)]; $this->next(); return $out; } $this->next(); return null; } public function getRow() { $out = ($this->valid() ? $this->current() : null); $this->next(); return $out; } public function getAll(): array { return iterator_to_array($this, false); } public function changes(): int { return $this->rows; } public function lastId(): int { return $this->id; } // constructor/destructor public function __construct(array $result, int $changes = 0, int $lastID = 0) { $this->set = $result; $this->rows = $changes; $this->id = $lastID; } public function __destruct() { } // PHP iterator methods public function valid() { return $this->pos < sizeof($this->set); } public function next() { $this->pos++; } public function current() { return $this->set[$this->key()]; } public function key() { return array_keys($this->set)[$this->pos]; } public function rewind() { $this->pos = 0; } }