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:5
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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or 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

Add a Patch

Pull Requests

Add a Pull Request

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-2020 The PHP Group
All rights reserved.
Last updated: Fri Nov 27 12:01:23 2020 UTC