database = $database; $this->handle = $handle; } public function __destruct() { if ($this->handle) { $this->handle->finalize(); } } public function getIterator() { while ($data = $this->handle->fetchArray(SQLITE3_ASSOC)) { yield $data; } } /** * @todo This looks terrible but there is no SQLite3::get_num_rows() implementation */ public function numRecords() { // Some queries are not iterable using fetchArray like CREATE statement if (!$this->handle->numColumns()) { return 0; } $this->handle->reset(); $c=0; while ($this->handle->fetchArray()) { $c++; } $this->handle->reset(); return $c; } }