Skip to content
Permalink
Browse files

Implementing resultSet and fetchResult in DboPostgres

  • Loading branch information...
lorenzo committed Oct 18, 2010
1 parent ad22bc3 commit edd448f0b89a99339de079a4ddd01f71ccf3519d
Showing with 11 additions and 14 deletions.
  1. +11 −14 cake/libs/model/datasources/dbo/dbo_postgres.php
@@ -696,20 +696,18 @@ function length($real) {
* @param unknown_type $results
*/
function resultSet(&$results) {
$this->results =& $results;
$this->map = array();
$num_fields = pg_num_fields($results);
$numFields = $results->columnCount();
$index = 0;
$j = 0;
while ($j < $num_fields) {
$columnName = pg_field_name($results, $j);
if (strpos($columnName, '__')) {
$parts = explode('__', $columnName);
$this->map[$index++] = array($parts[0], $parts[1]);
while ($j < $numFields) {
$column = $results->getColumnMeta($j);
if (strpos($column['name'], '__')) {
list($table, $name) = explode('__', $column['name']);
$this->map[$index++] = array($table, $name, $column['native_type']);
} else {
$this->map[$index++] = array(0, $columnName);
$this->map[$index++] = array(0, $column['name'], $column['native_type']);
}
$j++;
}
@@ -721,20 +719,19 @@ function resultSet(&$results) {
* @return unknown
*/
function fetchResult() {
if ($row = pg_fetch_row($this->results)) {
if ($row = $this->_result->fetch()) {
$resultRow = array();
foreach ($row as $index => $field) {
list($table, $column) = $this->map[$index];
$type = pg_field_type($this->results, $index);
foreach ($this->map as $index => $meta) {
list($table, $column, $type) = $meta;
switch ($type) {
case 'bool':
$resultRow[$table][$column] = $this->boolean($row[$index], false);
break;
case 'binary':
case 'bytea':
$resultRow[$table][$column] = pg_unescape_bytea($row[$index]);
$resultRow[$table][$column] = stream_get_contents($row[$index]);
break;
default:
$resultRow[$table][$column] = $row[$index];

0 comments on commit edd448f

Please sign in to comment.
You can’t perform that action at this time.