php.net |  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
Votes:6
Avg. Score:4.7 ± 0.5
Reproduced:6 of 6 (100.0%)
Same Version:2 (33.3%)
Same OS:2 (33.3%)
From: jeremy at jongsma dot org Assigned:
Status: Wont fix Package: PostgreSQL related
PHP Version: * OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jeremy at jongsma dot org
New email:
PHP Version: OS:

 

 [2006-04-10 16:12 UTC] jeremy at jongsma dot org
Description:
------------
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:

<?php
$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: ""

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-10 20:23 UTC] helly@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC