|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-08-12 16:29 UTC] ab@php.net
-Status: Open
+Status: Not a bug
[2013-08-12 16:29 UTC] ab@php.net
[2023-05-17 11:24 UTC] giw42161 at uooos dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 03:00:02 2025 UTC |
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.