php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44329 pg_query_params null does not pass correctly
Submitted: 2008-03-04 19:19 UTC Modified: 2008-11-03 01:00 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: tyler at sleekcode dot net Assigned:
Status: No Feedback Package: PostgreSQL related
PHP Version: 5.2.5 OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-03-04 19:19 UTC] tyler at sleekcode dot net
Description:
------------
Passing NULL via pg_query_params does not work resulting in situations where a possible NULL value must have a secondary branch of code to adjust the query accordingly.


Reproduce code:
---------------
Reproduce code:
---------------
using postgres 8x create this test table:

CREATE TABLE test
(
  id     serial PRIMARY KEY,
  name   text,
  extra  text,
);
INSERT INTO test (name,extra) VALUES ('Testing 123,'Testing');
INSERT INTO test (name) VALUES ('My extra is null');

<?php
$db = pg_connect("your connection string");

// query for all records where extra is NULL
IS NULL)
$res = pg_query_params("SELECT name FROM test WHERE extra=$1",array(NULL));

// print result, should be 'My extra is null'
print pg_fetch_result($res,0);
?>


Expected result:
----------------
pg_fetch_results should return the first result that matches the query and the code should print it.

Actual result:
--------------
The query does not run.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-04 19:20 UTC] tyler at sleekcode dot net
the query above is wrong, it should be:

pg_query_params("SELECT name FROM test WHERE extra IS $1",array(null));
 [2008-10-26 23:14 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2008-11-03 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 17:01:31 2024 UTC