|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-05-13 22:36 UTC] johannes@php.net
[2009-05-21 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 12:00:02 2025 UTC |
Description: ------------ Mysql ignores the IS NULL in the WHERE statement when the query is executed from php. In the example I give, the AddressID is auto_increment primary key. As you can see from the output, the address ID gets a value of 65 for the inserted row. I then DELETE WHERE AddressID IS NULL and the row is removed. It will also return the row when I execute SELECT * FROM Address WHERE AddressID IS NULL. It happens in with mysql_query, PDO::exec() or PDO::query() and with or without ` around the table name. Reproduce code: --------------- //PHP 5.2.9 on Hostmonster.com mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); mysql_select_db(DB_NAME); mysql_query("INSERT INTO `Address` (StreetAddress) VALUES ('blah')"); $result = mysql_query("SELECT * FROM `Address`"); while($row = mysql_fetch_assoc($result)){ print_r($row); } mysql_query("DELETE FROM `Address` WHERE `AddressID` IS NULL"); $result = mysql_query("SELECT * FROM `Address`"); while($row = mysql_fetch_assoc($result)){ print_r($row); } Expected result: ---------------- Array ( [AddressID] => 65 [NameOrCompany] => [StreetAddress] => blah [City] => [State] => [Zip] => [Country] => [DateTimeCreated] => [DateTimeModified] => ) Array ( [AddressID] => 65 [NameOrCompany] => [StreetAddress] => blah [City] => [State] => [Zip] => [Country] => [DateTimeCreated] => [DateTimeModified] => ) Actual result: -------------- Array ( [AddressID] => 65 [NameOrCompany] => [StreetAddress] => blah [City] => [State] => [Zip] => [Country] => [DateTimeCreated] => [DateTimeModified] => )