Hi.
The manual for pg_fetch_result () reads:
| [..] All forms of integer types are returned as integer values. All
| forms of float, and real types are returned as float values. Boolean
| is returned as "t" or "f". All other types, including arrays are
| returned as strings formatted in the same default PostgreSQL manner
| that you would see in the psql program.
This is not what happens when I call pg_fetch_result ():
pg_query($conn, "create table foo (id int)");
pg_query($conn, "insert into foo values (42)");
$result = pg_query($conn, "select * from foo");
$id = pg_fetch_result ($result, 0, 0);
var_dump($id);
// prints: string(2) "42"
I get the same behaviour for other types of integers, and for floats.
Booleans are returned as "t" and "f" (quite unfortunately, as both
strings evaluate to true in PHP), but that's at least what the manual
says should happen.
Is there any way to get PHP to do the casting for me, or do I really
have to convert all the values manually? I'm currently using PHP 4.3.1
with PostgreSQL 7.3.2.
TIA,
stefan
The manual for pg_fetch_result () reads:
| [..] All forms of integer types are returned as integer values. All
| forms of float, and real types are returned as float values. Boolean
| is returned as "t" or "f". All other types, including arrays are
| returned as strings formatted in the same default PostgreSQL manner
| that you would see in the psql program.
This is not what happens when I call pg_fetch_result ():
pg_query($conn, "create table foo (id int)");
pg_query($conn, "insert into foo values (42)");
$result = pg_query($conn, "select * from foo");
$id = pg_fetch_result ($result, 0, 0);
var_dump($id);
// prints: string(2) "42"
I get the same behaviour for other types of integers, and for floats.
Booleans are returned as "t" and "f" (quite unfortunately, as both
strings evaluate to true in PHP), but that's at least what the manual
says should happen.
Is there any way to get PHP to do the casting for me, or do I really
have to convert all the values manually? I'm currently using PHP 4.3.1
with PostgreSQL 7.3.2.
TIA,
stefan
Comment