|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-11-06 11:56 UTC] develar at gmail dot com
Description:
------------
PDO does not cast a variable with boolean type in bindValue, does not do execute and is silent.
I should cast manually - (int).
Reproduce code:
---------------
CREATE TABLE `test` (
`test` tinyint(1) NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
$Db = new PDO('mysql:host=localhost;dbname=test', 'root', '');
$Db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$Db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$boolean = 1;
$Pdo = $Db->prepare('INSERT INTO test VALUES (:boolean)');
$Pdo->bindValue(':boolean', isset($boolean), PDO::PARAM_INT);
$Pdo->execute();
Expected result:
----------------
array(1) { [0]=> array(1) { ["test"]=> string(1) "1" } }
Actual result:
--------------
array(0) { }
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 06:00:01 2025 UTC |
var_dump($Db->query('SELECT * FROM test')->fetchAll());