Skip to content

Commit

Permalink
Merge pull request #84 from kinglozzer/generators
Browse files Browse the repository at this point in the history
Update PostgreSQLQuery to use generators
  • Loading branch information
dhensby authored Mar 17, 2018
2 parents 5779887 + 25e57f4 commit bb5bda6
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions code/PostgreSQLQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,15 @@ public function __destruct()
}
}

public function seek($row)
public function getIterator()
{
pg_result_seek($this->handle, $row);
return pg_fetch_assoc($this->handle);
while ($data = pg_fetch_assoc($this->handle)) {
yield $data;
}
}

public function numRecords()
{
return pg_num_rows($this->handle);
}

public function nextRecord()
{
return pg_fetch_assoc($this->handle);
}
}

0 comments on commit bb5bda6

Please sign in to comment.