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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 19:01:33 2024 UTC