title: codeigniter pass array to query
body: <p>I'm trying to pass an array to a model which has a query. I'm not sure how to correctly pass the array or if i have to manipulate the array somehow.</p>
  
  <p>I have this array:</p>
  
  <pre><code>Array
  (
      [0] =&gt; 1
      [1] =&gt; 2
  )
  </code></pre>
  
  <p>I have a controller with this line:</p>
  
  <pre><code>$ratings = $this-&gt;login_model-&gt;get_ratings($mechanicIds);   // get the mechanic ratings
  </code></pre>
  
  <p>I have this model:</p>
  
  <pre><code>  function get_ratings($mechanicId)
      {
          $sql = "select m.mechanic_id, 
                     m.mechanic_name, 
                     m.city, 
                     m.state, 
                     count(mr.rating_id) as num_ratings, 
                     round(avg(mr.rating_id),2) avg_rating
                  from mechanic m, mechanic_rating mr, rating r
                  where m.mechanic_id in (?)
                  and m.mechanic_id = mr.mechanic_id
                  and mr.rating_id = r.rating_id";
  
          $query = $this-&gt;db-&gt;query($sql, $mechanicId);
  
          if($query-&gt;num_rows() &gt; 0)
          {
              return $query-&gt;result_array();
          }
          else
          {
              return false;
          }
      }
  </code></pre>
  
  <p>It actually returns results, but the problem is it only returns the results 1 row when it should be returning 2 since there are 2 results in my array. Anyone know what i'm doing wrong?</p>