Using standard php5-pgsql driver it results to me that, at least with the default php settings on ubuntu 10.04, the result values are not mapped to the standard php types. That is
- postresql::integer => php::int
- postresql::real => php::float
- etc
And return the result values being cast to strings. It creates sometimes quite a lot of headache when the locale of system does not coincide with the locale of database etc.
Is it possible somehow to get the appropriate casting in php? If not, any insight on why would very welcome!
EDIT:
The PDO solved the "postresql::integer=>php::int", but not for ex. "postresql::real=>php::float" it seems because of that PDO uses the native drivers that is pgsql as I understand. The issue with encoding is not a problem in my case, the only need is to map types exactly or at least as close as possible!
$sql = 'SELECT integer_field, numeric_field_10_2 FROM table';
foreach ($dbh->query($sql) as $row) {
var_dump($row);
}
----------------------------------------
array(4) {
["integer_field"]=>int(79)
["numeric_field_10_2"]=>string(6) "100.12"
}
Thanks, I.