From:             mmarais at centrapel dot com
Operating system: Linux version 2.6.18-6-686 (Debi
PHP version:      5.2.11
PHP Bug Type:     PDO related
Bug description:  "IN" statment badly handled in bindValue

Description:
------------
Using named paramters with the "IN" statement does not work correctly. Is
a list is used as a parameter with bindValue this list is interpreted as a
quoted string in the sql command

Reproduce code:
---------------
$arrEmployees = array(1,2,3,4,5,6);

$strSQL = "
   SELECT id, name
   FROM   employees
   WHERE  id in (:my_list);
";

$objPDOStatement = $objPDO->prepare($strSQL);
$objPDOStatement -> bindValue(':my_list', implode(',', $arrEmployees));
$objPDOStatement -> execute();

Expected result:
----------------
--------------
id | name
--------------
 1 | John Doe
 2 | Jack Doe
 3 | Gill Doe
 4 | Ralf Doe
 5 | Sven Doe
 6 | Carl Doe
--------------

Actual result:
--------------
--------------
id | name
--------------
 1 | John Doe
--------------

In sql cli, same results as if running  

   SELECT id, name
   FROM   employees
   WHERE  id in ('1,2,3,4,5,6'); -- List with quotes;

when expecting

   SELECT id, name
   FROM   employees
   WHERE  id in (1,2,3,4,5,6); -- List with no quotes;


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

Reply via email to