Bug #53960 [Opn->Bgs]: "Invalid parameter number" for multiple params equals in query

From: Date: Tue, 10 May 2011 08:03:11 +0000
Subject: Bug #53960 [Opn->Bgs]: "Invalid parameter number" for multiple params equals in query
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-160637@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53960&edit=1 ID: 53960 Updated by: uw@php.net Reported by: contato at andersonfraga dot net Summary: "Invalid parameter number" for multiple params equals in query -Status: Open +Status: Bogus Type: Bug Package: PDO related Operating System: Windows PHP Version: 5.3.5 Block user comment: N Private report: N New Comment: SQL - 2x hash_1: AND (NOME_CLIENTE LIKE :hash_1 OR ENDERECO_CLIENTE LIKE :hash_1) PHP bind - 1x hash_1, 1x hash_2: $statement->execute(Array( ':hash_1' => '%Anderson%', ':hash_2' => 0, Previous Comments: ------------------------------------------------------------------------ [2011-02-08 17:27:49] contato at andersonfraga dot net Description: ------------ This error is occurring when I use the same parameter several times in the query. In PHP 5.2.14, using Gentoo, it works perfectly. Already in versions 5.3.0 and 5.3.3 (using Windows on both), returns an exception. Bug or 'feature'? Test script: --------------- <?php try { $dbh = new PDO('mysql:/*irrelevant*/', Array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false, )); $select = "SELECT * FROM PR_CLIENTE WHERE DELETADO = 'N' AND (NOME_CLIENTE LIKE :hash_1 OR ENDERECO_CLIENTE LIKE :hash_1) ORDER BY ID_CLIENTE DESC LIMIT :hash_2;"; $statement = $dbh->prepare($select); $statement->execute(Array( ':hash_1' => '%Anderson%', ':hash_2' => 0, )); $fetch = $statement->fetchAll(PDO::FETCH_ASSOC); print_r($fetch); } catch(PDOException $e) { print_r($e->getMessage()); } ?> Expected result: ---------------- Array ( [0] => Array ( [ID_CLIENTE] => 29 (...) ) ) Actual result: -------------- SQLSTATE[HY093]: Invalid parameter number ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53960&edit=1

« previous php.bugs (#160637) next »