[Components] Problem with Database components on trunk version ?

Damien POBEL dpobel at free.fr
Sat Jan 27 14:33:46 CET 2007


Frederik Holljen a écrit :
> Hmm.. this looks correct to me (the query that is).  It's hard to say what is 
> going wrong without the definition you are using. Can you report a bug issue 
> including the definition?
After different tests, it seems that it is a problem related to my PDO
install.
I tried 2 very simple examples just using PDO without eZ Components (see 
below if you're interested) and the one with bindValue doesn't behave as 
expected... I keep on testing different cases, but it's weird !


With bindValue :
<?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($stmt);
var_dump($row);
$stmt->closeCursor();
?>

Result:

object(PDOStatement)#2 (1) {
   ["queryString"]=>
   string(40) "select * from `sew_sites` where `id`=:id"
}
array(0) {
}

Without bindValue :
<?php
$db = new PDO('mysql:host=localhost;dbname=sew', 'sew', 'sew');
$stmt = $db->prepare('select * from `sew_sites` where `id`=1');
$stmt->execute();
$row = $stmt->fetchAll( PDO::FETCH_ASSOC );
var_dump($stmt);
var_dump($row);
$stmt->closeCursor();
?>

Result:

object(PDOStatement)#2 (1) {
   ["queryString"]=>
   string(38) "select * from `sew_sites` where `id`=1"
}
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"
   }
}


-- 
Damien POBEL
http://pwet.fr/blog





More information about the Components mailing list