From: regli at yahoo dot com Operating system: Windows Vista PHP version: 5.2.5 PHP Bug Type: PDO related Bug description: The MySQL PDO driver resets variable content after bindParam on tinyint field
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 -- Edit bug report at http://bugs.php.net/?id=44707&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44707&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44707&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44707&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44707&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44707&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44707&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44707&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44707&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44707&r=support Expected behavior: http://bugs.php.net/fix.php?id=44707&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44707&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44707&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44707&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44707&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44707&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44707&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44707&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44707&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44707&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44707&r=mysqlcfg