handle = $handle; } public function __destruct() { if (is_resource($this->handle)) { pg_free_result($this->handle); } } public function getIterator() { while ($data = pg_fetch_assoc($this->handle)) { yield $data; } } public function numRecords() { return pg_num_rows($this->handle); } }