|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 08:00:01 2025 UTC |
the query above is wrong, it should be: pg_query_params("SELECT name FROM test WHERE extra IS $1",array(null));