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

 ID:                 53960
 User updated by:    contato at andersonfraga dot net
 Reported by:        contato at andersonfraga dot net
 Summary:            "Invalid parameter number" for multiple params
                     equals in query
 Status:             Bogus
 Type:               Bug
 Package:            PDO related
 Operating System:   Windows
 PHP Version:        5.3.5
 Block user comment: N
 Private report:     N

 New Comment:

Anyway... 

I think it should work, right?

'Even more because' it works in 5.2.14..


Previous Comments:
------------------------------------------------------------------------
[2011-05-10 10:03:11] u...@php.net

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,

------------------------------------------------------------------------
[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

Reply via email to