numCols = $result->numCols; parent::__construct(new Producer(function (callable $emit) use ($result, $fetch) { try { do { $next = $fetch(); // Request next result before current is consumed. yield $emit($result->fetchRow(pq\Result::FETCH_ASSOC)); $result = yield $next; } while ($result instanceof pq\Result); } finally { $this->complete(); } })); } public function numFields(): int { return $this->numCols; } }