Merge branch '2.3' into 2

This commit is contained in:
Robbie Averill 2019-11-27 17:28:00 -08:00
commit 0be39423a3

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,26 +75,35 @@ class PostgreSQLQuery extends Query
// Correct non-string types // Correct non-string types
if ($row) { if ($row) {
$record = []; return $this->parseResult($row);
foreach ($row as $i => $v) {
$k = $this->columnNames[$i];
$record[$k] = $v;
$type = pg_field_type($this->handle, $i);
if (isset(self::$typeMapping[$type])) {
if ($type === 'bool' && $record[$k] === 't') {
$record[$k] = 1;
// Note that boolean 'f' will be converted to 0 by this
} else {
settype($record[$k], self::$typeMapping[$type]);
}
}
}
return $record;
} }
return false; return false;
} }
/**
* @param array $row
* @return array
*/
protected function parseResult(array $row)
{
$record = [];
foreach ($row as $i => $v) {
$k = $this->columnNames[$i];
$record[$k] = $v;
$type = pg_field_type($this->handle, $i);
if (isset(self::$typeMapping[$type])) {
if ($type === 'bool' && $record[$k] === 't') {
$record[$k] = 1;
// Note that boolean 'f' will be converted to 0 by this
} else {
settype($record[$k], self::$typeMapping[$type]);
}
}
}
return $record;
}
} }