Bug #65421 [NEW]: 'field=NULL' should be 'field IS NULL'
| From: | schwalenberg1013 at gmail dot com | Date: | Thu, 08 Aug 2013 13:26:34 +0000 |
| Subject: | Bug #65421 [NEW]: 'field=NULL' should be 'field IS NULL' | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-180803@lists.php.net to get a copy of this message | ||
From: schwalenberg1013 at gmail dot com
Operating system: Linux
PHP version: 5.5.1
Package: PDO related
Bug Type: Bug
Bug description:'field=NULL' should be 'field IS NULL'
Description:
------------
When using PDO bindParam when it receives a NULL value the ultimate result
that
it sends to MySql is field=NULL instead of field IS NULL.
Test script:
---------------
$editStmt = $db->prepare("UPDATE employee SET
startDate=:startDate,department=:department,jobTitle=:jobTitle WHERE
name=:emplName AND startDate=:oldStartDate AND department=:oldDepartment
AND jobTitle=:oldJobTitle LIMIT 1");
$editStmt->bindParam('startDate',$startDate);
$editStmt->bindParam('department',$department);
$editStmt->bindParam('jobTitle',$jobTitle);
$editStmt->bindParam('emplName',$emplName);
$editStmt->bindParam('oldStartDate',$oldStartDate);
$editStmt->bindParam('oldDepartment',$oldDepartment);
$editStmt->bindParam('oldJobTitle',$oldJobTitle);
// catchException($editStmt,$db);
$editStmt->execute();
$editResult = $editStmt->fetchAll(PDO::FETCH_ASSOC);
/* If any one of these variables happens to be NULL then the whole
statement fails because it will output, for example, 'AND department=NULL'
instead of 'AND department IS NULL' */
Expected result:
----------------
MySql will not except field=NULL properly it should be field IS NULL
Actual result:
--------------
I can do this in MySql however when using PDO I have to create an entirely
different statement myself for the exceptions of NULL values which becomes
very
tedious a problem I never had using the depreciated mysql functions or when
using
mysqli.
--
Edit bug report at https://bugs.php.net/bug.php?id=65421&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65421&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=65421&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65421&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=65421&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=65421&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65421&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=65421&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=65421&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=65421&r=support
Expected behavior: https://bugs.php.net/fix.php?id=65421&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=65421&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=65421&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=65421&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65421&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=65421&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=65421&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=65421&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65421&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65421&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=65421&r=mysqlcfg