Merge pull request #99 from sminnee/fix-9097

FIX: Don’t drop first row on repeated iteration
This commit is contained in:
Sam Minnée 2019-07-03 14:27:21 +12:00 committed by GitHub
commit f2ec228c72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 20 deletions

View File

@ -58,8 +58,10 @@ class PostgreSQLQuery extends Query
public function seek($row) public function seek($row)
{ {
pg_result_seek($this->handle, $row); // Specifying the zero-th record here will reset the pointer
return $this->nextRecord(); $result = pg_fetch_array($this->handle, $row, PGSQL_NUM);
return $this->parseResult($result);
} }
public function numRecords() public function numRecords()
@ -73,6 +75,18 @@ class PostgreSQLQuery extends Query
// Correct non-string types // Correct non-string types
if ($row) { if ($row) {
return $this->parseResult($row);
}
return false;
}
/**
* @param array $row
* @return array
*/
protected function parseResult(array $row)
{
$record = []; $record = [];
foreach ($row as $i => $v) { foreach ($row as $i => $v) {
@ -92,7 +106,4 @@ class PostgreSQLQuery extends Query
return $record; return $record;
} }
return false;
}
} }