From:             
Operating system: Debian Lenny
PHP version:      5.2.14
Package:          PDO related
Bug Type:         Bug
Bug description:bug in prepare statement

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 bug report at http://bugs.php.net/bug.php?id=52637&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52637&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52637&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52637&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52637&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52637&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52637&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52637&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52637&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52637&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52637&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52637&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52637&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52637&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52637&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52637&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52637&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52637&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52637&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52637&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52637&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52637&r=mysqlcfg

Reply via email to