2008年9月18日星期四

[fw-db] Is this normal behaviour for prepared statements?

Hi all,

I've got this query in one of my zend_db_table_abstract extended models:


$sql = "SELECT * FROM Reacties
WHERE (Isat = :isat AND Vestiging_ID = :vestiging)
OR (Parent_ID IN (SELECT Reactie_ID FROM Reacties
WHERE (Isat = :isat2 AND Vestiging_ID = :vestiging2)))
ORDER BY Datum ASC";
$stm = $dbh->query($sql, array(':isat'=>$isat,
':vestiging'=>$vestiging, ':isat2'=>$isat, ':vestiging2'=>$vestiging));

This works fine, as expected.

However, first I had this:
$sql = "SELECT * FROM Reacties
WHERE (Isat = :isat AND Vestiging_ID = :vestiging)
OR (Parent_ID IN (SELECT Reactie_ID FROM Reacties
WHERE (Isat = :isat AND Vestiging_ID = :vestiging)))
ORDER BY Datum ASC";
$stm = $dbh->query($sql, array(':isat'=>$isat,
':vestiging'=>$vestiging));

This didn't work, which surprised me. I supposed I could define my named
params :isat and :vestiging just once in the bind; however, it appears I
have to define them twice, as denoted by my example.

Is this normal behaviour for pdo-statements? Or is this peculiar for
Zend_Db_Table_Abstract?

Thanks for any info!

GJ
--
View this message in context: http://www.nabble.com/Is-this-normal-behaviour-for-prepared-statements--tp19560273p19560273.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: