$crw=array();
for($j=0;$j<$nf;$j++){
$fn=$fnames[$j];
- if($dbScheme->isIntColumn($table,$fn))$crw[$j]=$row[$j]+0;else
- if($dbScheme->isBlobColumn($table,$fn))$crw[$j]=pg_unescape_bytea($row[$j]);else
- if($dbScheme->isBoolColumn($table,$fn))$crw[$j]=$row[$j]=='t';
- else $crw[$j]=$row[$j];
+ if(pg_field_is_null($res,$i,$j))
+ $crw[$j]=null;
+ else
+ if($dbScheme->isIntColumn($table,$fn))
+ $crw[$j]=$row[$j]+0;
+ else
+ if($dbScheme->isBlobColumn($table,$fn))
+ $crw[$j]=pg_unescape_bytea($row[$j]);
+ else
+ if($dbScheme->isBoolColumn($table,$fn))
+ $crw[$j]=$this->unescapeBool($row[$j]);
+ else //any other type: hope string is ok
+ $crw[$j]=$row[$j];
+ //copy to named index
$crw[$fn]=$crw[$j];
}
$ret[]=$crw;
if($s === false||$s===null) return "NULL";
return "'".pg_escape_bytea($this->dbhdl,$s)."'";
}
+
+ /**internal: unescape a postgres bool towards PHP bool*/
+ protected function unescapeBool($b)
+ {
+ if($b===null)return null;
+ if(is_bool($b))return $b;
+ if(is_numeric($b))return ($b+0)!=0;
+ $b=strtolower($b);
+ if($b=="t" || $b=="true" || $b=="yes" || $b=="y" || $b=="on")return true;
+ else return false;
+ }
};
?>
\ No newline at end of file