note 92236 added to pdostatement.bindparam
| From: | drtebi at yahoodotcom | Date: | Wed, 15 Jul 2009 10:22:02 +0000 |
| Subject: | note 92236 added to pdostatement.bindparam | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-158325@lists.php.net to get a copy of this message | ||
@Alex wrote:
trying to use:
<?php
....
$sql = 'select * from mytable where id in(:ids)';
$stmt->bindParam(':ids', '1,2,3,4');
....
?>
will fail.
---
Yes it fails because bindParam() expects a data_type, or, if none is set, it will use
PDO::PARAM_STR, which will result in this SQL query:
select * from mytable where id in('1,2,3,4');
This of course won't work as intended (it will only find a result for 1). I am having the same
problem but unfortunately no other solution than "manually" replacing the values for the
IN() operator.
----
Server IP: 209.41.74.194
Probable Submitter: 69.12.130.153
----
Manual Page -- http://www.php.net/manual/en/pdostatement.bindparam.php
Edit -- https://master.php.net/note/edit/92236
Del: integrated -- https://master.php.net/note/delete/92236/integrated
Del: useless -- https://master.php.net/note/delete/92236/useless
Del: bad code -- https://master.php.net/note/delete/92236/bad+code
Del: spam -- https://master.php.net/note/delete/92236/spam
Del: non-english -- https://master.php.net/note/delete/92236/non-english
Del: in docs -- https://master.php.net/note/delete/92236/in+docs
Del: other reasons-- https://master.php.net/note/delete/92236
Reject -- https://master.php.net/note/reject/92236
Search -- https://master.php.net/manage/user-notes.php