mirror of
https://github.com/silverstripe/silverstripe-postgresql
synced 2024-10-22 17:05:45 +02:00
Merge pull request #137 from creative-commoners/pulls/3/revert
FIX Revert using generators
This commit is contained in:
commit
2946e07319
@ -2,7 +2,6 @@
|
||||
|
||||
namespace SilverStripe\PostgreSQL;
|
||||
|
||||
use Iterator;
|
||||
use SilverStripe\ORM\Connect\Query;
|
||||
|
||||
/**
|
||||
@ -57,11 +56,12 @@ class PostgreSQLQuery extends Query
|
||||
}
|
||||
}
|
||||
|
||||
public function getIterator(): Iterator
|
||||
public function seek($row)
|
||||
{
|
||||
while ($row = pg_fetch_array($this->handle, null, PGSQL_NUM)) {
|
||||
yield $this->parseResult($row);
|
||||
}
|
||||
// Specifying the zero-th record here will reset the pointer
|
||||
$result = pg_fetch_array($this->handle, $row, PGSQL_NUM);
|
||||
|
||||
return $this->parseResult($result);
|
||||
}
|
||||
|
||||
public function numRecords()
|
||||
@ -69,6 +69,18 @@ class PostgreSQLQuery extends Query
|
||||
return pg_num_rows($this->handle);
|
||||
}
|
||||
|
||||
public function nextRecord()
|
||||
{
|
||||
$row = pg_fetch_array($this->handle, null, PGSQL_NUM);
|
||||
|
||||
// Correct non-string types
|
||||
if ($row) {
|
||||
return $this->parseResult($row);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $row
|
||||
* @return array
|
||||
|
Loading…
Reference in New Issue
Block a user