From:             tyler at sleekcode dot net
Operating system: Windows
PHP version:      5.2.5
PHP Bug Type:     PostgreSQL related
Bug description:  pg_query_params NULL not passing correctly

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:
---------------
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");

// set postgresql to allow = NULL instead of requiring IS NULL
pg_query("set transform_null_equals to on");

// query for all records where extra = NULL (postgres converts to extra 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:
----------------
The code should return the first result that matches the query.

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

-- 
Edit bug report at http://bugs.php.net/?id=44196&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44196&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44196&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44196&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44196&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44196&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44196&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44196&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44196&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44196&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44196&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44196&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44196&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44196&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44196&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44196&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44196&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44196&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44196&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44196&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44196&r=mysqlcfg

Reply via email to