Bug->Req #66632 [Opn]: bindValue() and bindParam() fail silently for PARAM_BOOL datatype

From: Date: Tue, 25 Feb 2014 12:22:20 +0000
Subject: Bug->Req #66632 [Opn]: bindValue() and bindParam() fail silently for PARAM_BOOL datatype
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184411@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66632&edit=1 ID: 66632 Updated by: uw@php.net Reported by: david at beroff dot com Summary: bindValue() and bindParam() fail silently for PARAM_BOOL datatype Status: Open -Type: Bug +Type: Feature/Change Request Package: PDO MySQL Operating System: Linux PHP Version: 5.4.24 Block user comment: N Private report: N New Comment: PARAM_INT works just fine for me with mysqlnd. Use INT... The MySQL PDO driver code does not cover PARAM_BOOL. Hence, the driver signals a failure to the calling PDO core for PDO_PARAM_EVT_EXEC_PRE. The core, however, ignores the failure and returns true for a failed bind*() call. You filed the bug against PDO_MySQL. From PDO_MySQL perspective it is a feature request. If it was filed against PDO, I'd call it a bug. Previous Comments: ------------------------------------------------------------------------ [2014-02-03 12:39:12] david at beroff dot com Description: ------------ bindValue( ... PDO::PARAM_BOOL ) and bindParam( ... PDO::PARAM_BOOL ) appear to cause the subsequent execute() to not do anything, as well as to not report that the operation failed. Reported earlier, (2006), but suspended due to no feedback: https://bugs.php.net/bug.php?id=38386 https://bugs.php.net/bug.php?id=38546 Apparently may have already been fixed for Postgres: https://bugs.php.net/bug.php?id=62593 May also be related to: https://bugs.php.net/bug.php?id=41365 https://bugs.php.net/bug.php?id=57489 Software versions: Linux Version 2.6.32.39-grsec-3.mosso5.1.x86_64 PHP Version 5.3.20 (external host; unable to upgrade) PHP MySQL library version 5.0.77 MySQL server version 5.1.70 Test script: --------------- <html><body><pre><?php try { $db = new PDO( "mysql:host=HOSTNAME;dbname=DATABASE", "USERNAME", "PASSWORD", array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ) ); $db->exec( "DROP TABLE IF EXISTS TestPDO;" ); $db->exec( "CREATE TABLE TestPDO (ColT BOOLEAN, ColF BOOLEAN) ENGINE = InnoDB;" ); $stmt = $db->prepare( "INSERT INTO TestPDO (ColT, ColF) VALUES (:ColT, :ColF);" ); $stmt->bindValue( ":ColT", TRUE, PDO::PARAM_BOOL ); $stmt->bindValue( ":ColF", FALSE, PDO::PARAM_BOOL ); $stmt->execute(); // Suggested workaround (from bug #38546 [2007-04-11 15:26 UTC]) doesn't work: $colT = TRUE; $colF = FALSE; $stmt->bindParam( ":ColT", $colT, PDO::PARAM_BOOL ); $stmt->bindParam( ":ColF", $colF, PDO::PARAM_BOOL ); $stmt->execute(); // New proposed workaround: $stmt->bindValue( ":ColT", $colT ? 1 : 0, PDO::PARAM_INT ); $stmt->bindValue( ":ColF", $colF ? 1 : 0, PDO::PARAM_INT ); $stmt->execute(); foreach ($db->query( "SELECT * FROM TestPDO" ) as $row) print_r($row); $db = NULL; } catch (PDOException $e) { echo $e->getMessage(); } ?></pre></body></html> Expected result: ---------------- Array ( [ColT] => 1 [ColF] => 0 ) Array ( [ColT] => 1 [ColF] => 0 ) Array ( [ColT] => 1 [ColF] => 0 ) Actual result: -------------- Array ( [ColT] => 1 [ColF] => 0 ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66632&edit=1

« previous php.bugs (#184411) next »