title: Can I set multiple Codeigniter Where criteria from an array?
body: <p>I am trying to get data from a database that meets multiple criteria of an array.</p>
  
  <p>The array is something like this: </p>
  
  <pre><code>Array ([21] =&gt; 1,[23] =&gt; 0,[19] =&gt; 1);
  </code></pre>
  
  <p>With the key being a Question ID and the values being either yes or no.</p>
  
  <p>I need to find the movie where the value for <code>question_id = 21</code> is <code>1</code>, value for <code>question_id = 23</code> is <code>0</code> and value for <code>question_id = 19</code> is <code>1</code>.  The way I have them stored is like this: </p>
  
  <p><img src="https://i.stack.imgur.com/QZ37t.png" alt="enter image description here"></p>
  
  <p>So my first thought was get the data for each and then put them in a bigger array.  If the movie shows up the same amount of times as the number of elements in the array, then I consider it a good match.  But this seems inefficient.  I would rather just find the movies that match the criteria.</p>
  
  <p>Since there are <code>movie_id</code> records with the same value, is there a way to write something like this?:</p>
  
  <pre><code>foreach($array as $key=&gt;$value){
  $i++;
  $this-&gt;db-&gt;where('question_id', $key);
  $this-&gt;db-&gt;where('value', $value);
  
  }
  $this-&gt;db-&gt;from('movies_values');
      $query = $this-&gt;db-&gt;get();
      $res = $query-&gt;result();
      array_push($main,$res);
  </code></pre>
  
  <p>The thought behind this is to create a loop of all the <code>WHERE</code>s.  And then run the query using those where values.  This doesn't seem to work, is there something else I can do?</p>