Edit report at http://bugs.php.net/bug.php?id=52637&edit=1

 ID:                 52637
 User updated by:    angelo dot courtel at laposte dot net
 Reported by:        angelo dot courtel at laposte dot net
 Summary:            bug in prepare statement
-Status:             Feedback
+Status:             Open
 Type:               Bug
 Package:            PDO related
 Operating System:   Debian Lenny
 PHP Version:        5.2.14
 Block user comment: N

 New Comment:

Hi, I use PostGreSql Pdo driver

Thks


Previous Comments:
------------------------------------------------------------------------
[2010-08-19 01:17:32] [email protected]

What PDO driver are you using?

------------------------------------------------------------------------
[2010-08-18 18:18:03] angelo dot courtel at laposte dot net

Description:
------------
Hi



when I execute a prepared query which use twice, or more, a same
parameters, it 

returns an error : in french : ERREUR:  n'a pas pu déterminer le type
de données 

du paramètres $3



ie. : this query don't works

$sReq = 'select *

        from categorie

        left join budget on bud_cat = cat_cod and bud_moi = :month and bud_ann
= 

:year

        left join operation on ope_cat = cat_cod and ope_moi = :month and 

ope_ann = :year

        where cat_cod = :categorie';

$rCategorie = $oAppli->getDb()->prepare($sReq);

$rCategorie->bindParam(':month', date('m'));

$rCategorie->bindParam(':categorie', $sCategorie);

$rCategorie->bindParam(':year', date('Y'));

if ($rCategorie->execute())



but if I add "--  :year :categorie :month" at the beginning of the
query, it 

works !!!

I thinks PDO don't like seeing a repeated parameter before seens all the


parameters (the :month appears twice before :categorie, almost with the
comment 

at the beginning, PDO see all parameters at start)



Sorry for my english I'm french guy.



Thks

Test script:
---------------
//don't work

$sReq = 'select *

        from categorie

        left join budget on bud_cat = cat_cod and bud_moi = :month and bud_ann
= :year

        left join operation on ope_cat = cat_cod and ope_moi = :month and
ope_ann = :year

        where cat_cod = :categorie';

$rCategorie = $oAppli->getDb()->prepare($sReq);

$rCategorie->bindParam(':month', date('m'));

$rCategorie->bindParam(':categorie', $sCategorie);

$rCategorie->bindParam(':year', date('Y'));

if ($rCategorie->execute())



//works fine



$sReq = '--  :year :categorie :month

        select *

        from categorie

        left join budget on bud_cat = cat_cod and bud_moi = :month and bud_ann
= :year

        left join operation on ope_cat = cat_cod and ope_moi = :month and
ope_ann = :year

        where cat_cod = :categorie';

$rCategorie = $oAppli->getDb()->prepare($sReq);

$rCategorie->bindParam(':month', date('m'));

$rCategorie->bindParam(':categorie', $sCategorie);

$rCategorie->bindParam(':year', date('Y'));

if ($rCategorie->execute())





------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52637&edit=1

Reply via email to