|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-09-24 09:02 UTC] uw@php.net
[2012-03-12 10:19 UTC] alvaro at demogracia dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 08:00:01 2025 UTC |
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;