Bug #52637 [Opn->Fbk]: bug in prepare statement

From: Date: Wed, 18 Aug 2010 23:17:32 +0000
Subject: Bug #52637 [Opn->Fbk]: bug in prepare statement
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-153592@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52637&edit=1

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

 New Comment:

What PDO driver are you using?


Previous Comments:
------------------------------------------------------------------------
[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


Thread (11 messages)

« previous php.bugs (#153592) next »