title: Code Igniter Query Binding
body: <p>I have the following query to select rows from a table based on rownumber.</p>
  
  <pre><code>$targeted_rows = implode(",",$wanted);
  
  
  $sql =  "SELECT * FROM (
       SELECT @row:=@row+1 as rownum, productsa.* FROM (
       SELECT @row:=0
              )r,productsa
              )ranked
              WHERE rownum IN (?)  ";
  $q = $this-&gt;db-&gt;query($sql, $targeted_rows);
  
  if($q-&gt;num_rows() &gt; 0) {
      foreach ($q-&gt;result() as $row) {
      $data[] = $row;
  }
  return $data;
  };
  </code></pre>
  
  <p>Currently my query is being executed like this. With the quotes around numbers and it is not working. </p>
  
  <pre><code>SELECT * FROM (
                 SELECT @row:=@row+1 as rownum, productsa.* FROM (
                    SELECT @row:=0
                 )r,productsa
              )ranked
              WHERE rownum IN ('1,4,7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58,61,64,67,70,73,76,79,82,85,88,91,94,97,100,103,106,109,112,115,118,121,124,127,130,133,136,139,142,145,148,151,154,157,160,163,166,169,172')  
  </code></pre>
  
  <p>But when I manually execute the query without the quotes it works fine. I am at a completely loss on how to do the binding without the quotes showing up in the query. </p>
  
  <p>edit: I've tried removing the implode and using the below code but I get the same problem</p>
  
  <pre><code>foreach ($wanted as $value){ 
    $targeted_rows .= $value . ","; 
  }    
  $this-&gt;db-&gt;escape($targeted_rows);
  </code></pre>