|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37031 pg_query_params not converting boolean false values correctly
Submitted: 2006-04-10 16:12 UTC Modified: 2006-04-10 20:23 UTC
Avg. Score:4.6 ± 0.5
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:2 (40.0%)
From: jeremy at jongsma dot org Assigned:
Status: Wont fix Package: PostgreSQL related
PHP Version: * OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
43 - 36 = ?
Subscribe to this entry?

 [2006-04-10 16:12 UTC] jeremy at jongsma dot org
pg_query_params seems to be converting boolean "false" parameters to an empty string before sending the query to Postgres, resulting in the following error:

ERROR: invalid input syntax for type boolean: ""

Reproduce code:
Create a table:

CREATE TABLE test (id serial8, flag boolean);

Execute this php script:

$conn = pg_connect('host=localhost dbname=test user=user password=pass');
pg_query_params($conn, 'INSERT INTO test (flag) VALUES ($1)', array(false));

Expected result:
A new row should be inserted with the correct boolean field value.

Actual result:
ERROR: invalid input syntax for type boolean: ""


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-10 20:23 UTC]
pg_query_params expects the data as binary data otherwise you could have been using pg_convert() easily to convert your php data to postgres data.

That said you need to convert true to t and false to f.

Instead you could be using pg_insert, which allows to do the correct conversion automatically.

Need to figure out an easy way to get the necessary meta information to allow pg_query_params() to do the conversion correct. Until then this gets Won't fix status.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Oct 16 11:03:33 2021 UTC