ID: 47199 Comment by: andrew at labyrinth-it dot co dot uk Reported By: andrew at labyrinth-it dot co dot uk Status: Feedback Bug Type: PostgreSQL related Operating System: Linux (Fedora) PHP Version: 5.2.8 New Comment:
I am using: PHP 5.2.10-dev (cli) (built: May 19 2009 15:40:36) and still get the same error result. This error is also in the pg_update function, where NULl values are compared with "= NULL" rather than "IS NULL" in the WHERE part of the generated SQL. Previous Comments: ------------------------------------------------------------------------ [2009-05-15 00:31:00] j...@php.net Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://windows.php.net/snapshots/ ------------------------------------------------------------------------ [2009-01-23 11:46:35] andrew at labyrinth-it dot co dot uk Description: ------------ pg_delete uses incorrect syntax for NULL columns. The code generated compares values with "col = NULL" instead of "col IS NULL". As a result, the row is not matched so is not deleted. Reproduce code: --------------- <?php $db = pg_connect("host=localhost dbname=andrew user=andrew password=andrew"); $sql = 'SELECT * FROM demo'; $qry = pg_query($sql); while ($row = pg_fetch_array($qry, null, PGSQL_ASSOC)) { print_r($row); pg_delete($db,'demo',$row); //1 print(pg_delete($db,'demo',$row,PGSQL_DML_STRING)) } pg_free_result($qry); $qry = pg_query($sql); while ($row = pg_fetch_array($qry, null, PGSQL_ASSOC)) { print_r($row); //2 } pg_free_result($qry); pg_close($db); Expected result: ---------------- The first loop should read and display all rows in the table, and then delete the rows. The second loop should not display any data at all. --- Array ( [id] => 1 [col1] => ) DELETE FROM demo WHERE id=1 AND col1 IS NULL; Actual result: -------------- When this runs, the second loop displays results for tables that have NULL columns at the start of the run. --- Array ( [id] => 1 [col1] => ) DELETE FROM demo WHERE id=1 AND col1=NULL; Array ( [id] => 1 [col1] => ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47199&edit=1