#44329 [Opn]: pg_query_params null does not pass correctly

From: Date: Tue, 04 Mar 2008 19:20:39 +0000
Subject: #44329 [Opn]: pg_query_params null does not pass correctly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-122928@lists.php.net to get a copy of this message
ID: 44329 User updated by: tyler at sleekcode dot net Reported By: tyler at sleekcode dot net Status: Open Bug Type: PostgreSQL related Operating System: Multiple PHP Version: 5.2.5 New Comment: the query above is wrong, it should be: pg_query_params("SELECT name FROM test WHERE extra IS $1",array(null)); Previous Comments: ------------------------------------------------------------------------ [2008-03-04 19:19:38] 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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44329&edit=1

« previous php.bugs (#122928) next »