|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-07-03 15:08 UTC] uw@php.net
[2008-07-03 19:55 UTC] uw@php.net
[2008-10-21 11:28 UTC] jani@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 06:00:01 2025 UTC |
Description: ------------ In a prepare/bindParam scenario where the variable is already preset before the bindParam has been executed, a boolean field gets reset by the driver. In the case of TRUE it resets it to "1" and in the case of FALSE it rests it to ''. Obviously this is highly undesirable as I get the input parameters in a function and then simply execute the prepare/bindParam. However, as the database field is defined as tinyint, I naturally get a PDOException. I tested the same code with IBM DB2 and this issue does not occur and it works perfectly (obviously the field definition is smallint). If I reset the field after bindParam to FALSE and then again execute the statement, it works perfectly as it should. The problem seems clearly to be in bindParam. I tested this using the latest php_pdo_mysql.dll php-5.2.1(5_2) from 2008-01-11. Reproduce code: --------------- $stmt = db::getInstance()->prepare("INSERT INTO session (sessionName, privateSessionBool); $stmt->bindParam(':sessionName', $sessionName); $privateSessionBool) = false; echo $privateSessionBool; // here is where the problem occurs. $stmt->bindParam(':privateSessionBool', $privateSessionBool); echo $privateSessionBool; Expected result: ---------------- The second bindParam statement should NOT change the field value of privateSessionBool to ''. In fact bindParam should NEVER alter a fields value. Note that it even changes TRUE booleans to '1' instead of leaving them alone. I did not observe this behavior in other field types. Actual result: -------------- The first echo results in "false" whereas the second results in ''. Any insert then results in: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'privateSessionBool' at row 1