title: Can I bind an array to an IN() condition in a PDO query?
body: <p>I'm curious to know if it's possible to bind an array of values to a placeholder using PDO.  The use case here is attempting to pass an array of values for use with an <code>IN()</code> condition.  </p>
  
  <p>I'd like to be able to do something like this:</p>
  
  <pre><code>&lt;?php
  $ids=array(1,2,3,7,8,9);
  $db = new PDO(...);
  $stmt = $db-&gt;prepare(
      'SELECT *
       FROM table
       WHERE id IN(:an_array)'
  );
  $stmt-&gt;bindParam('an_array',$ids);
  $stmt-&gt;execute();
  ?&gt;
  </code></pre>
  
  <p>And have PDO bind and quote all the values in the array.</p>
  
  <p>At the moment I'm doing:</p>
  
  <pre><code>&lt;?php
  $ids = array(1,2,3,7,8,9);
  $db = new PDO(...);
  foreach($ids as &amp;$val)
      $val=$db-&gt;quote($val); //iterate through array and quote
  $in = implode(',',$ids); //create comma separated list
  $stmt = $db-&gt;prepare(
      'SELECT *
       FROM table
       WHERE id IN('.$in.')'
  );
  $stmt-&gt;execute();
  ?&gt;
  </code></pre>
  
  <p>Which certainly does the job, but just wondering if there's a built in solution I'm missing?</p>