note 92236 deleted from pdostatement.bindparam by thiago
| From: | thiago@php.net | Date: | Wed, 15 Jul 2009 12:05:00 +0000 |
| Subject: | note 92236 deleted from pdostatement.bindparam by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-158330@lists.php.net to get a copy of this message | ||
Note Submitter: dr tebi @ yahoo dot com
----
@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.