Bug #66632 [NEW]: bindValue() and bindParam() fail silently for PARAM_BOOL datatype
| From: | david at beroff dot com | Date: | Mon, 03 Feb 2014 12:39:13 +0000 |
| Subject: | Bug #66632 [NEW]: bindValue() and bindParam() fail silently for PARAM_BOOL datatype | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-184131@lists.php.net to get a copy of this message | ||
From: david at beroff dot com
Operating system: Linux
PHP version: 5.4.24
Package: PDO MySQL
Bug Type: Bug
Bug description:bindValue() and bindParam() fail silently for PARAM_BOOL datatype
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 bug report at https://bugs.php.net/bug.php?id=66632&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66632&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66632&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66632&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66632&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66632&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66632&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66632&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66632&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66632&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66632&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66632&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66632&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66632&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66632&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66632&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66632&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66632&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66632&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66632&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66632&r=mysqlcfg