|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-01-29 17:44 UTC] dpobel at free dot fr
[2008-05-13 09:00 UTC] johannes at schlueters dot de
[2011-05-26 08:20 UTC] johannes at schlueters dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 11:00:01 2025 UTC |
Description: ------------ It seems that prepared statements with bindValue (or bindParams) don't work as expected. The two examples below should output the same things. Configuration : PHP 5.1.6 (ubuntu package) MySQL 4.1.15 (ubuntu package) PDO_MYSQL compiled with libmysqlclient14-dev (header for MySQL 4.1) and libmysqlclient15-dev (header for MySQL 5.0) with the same result. Reproduce code: --------------- test_pdo.php <?php $db = new PDO('mysql:host=localhost;dbname=sew', LOGIN, PASSWORD); $stmt = $db->prepare('select * from `sew_sites` where `id`=:id'); $stmt->bindValue(':id', 1); $stmt->execute(); $row = $stmt->fetchAll( PDO::FETCH_ASSOC ); var_dump($row); $stmt->closeCursor(); ?> test_pdo_simple.php <?php $db = new PDO('mysql:host=localhost;dbname=sew', LOGIN, PASSWORD); $stmt = $db->prepare('select * from `sew_sites` where `id`=1'); $stmt->execute(); $row = $stmt->fetchAll( PDO::FETCH_ASSOC ); var_dump($row); $stmt->closeCursor(); ?> Expected result: ---------------- These two scripts should output exactly same data. Actual result: -------------- > tigrou@dedipwet[88.191.30.29]:~/tmp$ php5 test_pdo.php array(0) { } > tigrou@dedipwet[88.191.30.29]:~/tmp$ php5 test_pdo_simple.php array(1) { [0]=> array(4) { ["id"]=> string(1) "1" ["title"]=> string(15) "~tigrou/pwet.fr" ["url"]=> string(14) "http://pwet.fr" ["pages"]=> string(5) "60000" } }