title: Unable to add Codeigniter where in clause and where clause in mysql query
body: <p>I am new to codeigniter and working on a project where I need to add search filters on a page. The way its been setup under applications/core there is a MY_Model.php file and here it the get_result function it.</p>
  
  <pre><code>function get_result() {
    $this-&gt;db-&gt;from($this-&gt;tableName . ' ' . $this-&gt;alias);
    $this-&gt;db-&gt;select($this-&gt;selectFields, FALSE);
  
    for($j=0;$j&lt;count($this-&gt;arrJoins);$j++){
      $this-&gt;db-&gt;join($this-&gt;arrJoins[$j][0], $this-&gt;arrJoins[$j][1], $this-&gt;arrJoins[$j][2]);
    }
  
    $this-&gt;db-&gt;like($this-&gt;arrLike);
    $this-&gt;db-&gt;or_like($this-&gt;arrOrLike);
    if(isset($this-&gt;custLikeStr) &amp;&amp; count($this-&gt;custLikeStr) &gt; 0){
      $this-&gt;db-&gt;where($this-&gt;custLikeStr);
    }
    $this-&gt;db-&gt;where($this-&gt;arrWhere);
    $this-&gt;db-&gt;order_by($this-&gt;sortBy, $this-&gt;sortOrder);
    $query = $this-&gt;db-&gt;get()-&gt;result();
    //echo '&lt;br&gt;'.$this-&gt;db-&gt;last_query();
    return $query;
  }
  </code></pre>
  
  <p>There is a get_where function to build all where clauses</p>
  
  <pre><code>function get_where() {
    foreach($this-&gt;arrWhereInputs as $arrWhereInput) {
      if(isset($this-&gt;$arrWhereInput) &amp;&amp; $this-&gt;$arrWhereInput != ''){
        $this-&gt;arrWhere[$this-&gt;fieldAlias[$arrWhereInput].'.'.$arrWhereInput] = trim($this-&gt;$arrWhereInput);
      }
    }
    return $this-&gt;arrWhere;
  }
  </code></pre>
  
  <p>And in the model file for the application so under application/models here is there is a select function we need to call to get results. </p>
  
  <pre><code>function select(){
      /* for search list */
      $this-&gt;arrLikeInputs = array('stock_title', 'stock_id', 'price_band', );
      $this-&gt;arrWhereInputs = array();
      $this-&gt;arrWhere = array();
  
      if ($this-&gt;input-&gt;post('record_per_page') != '') {
          $records_per_page = $this-&gt;input-&gt;post('record_per_page');
      } else {
          $records_per_page = ROWS_PER_PAGE;
      }
  
      if (!(isset($this-&gt;record_per_page) &amp;&amp; $this-&gt;record_per_page != '')) {
          $this-&gt;record_per_page = ROWS_PER_PAGE;
      }
  
      $this-&gt;arrLike = $this-&gt;get_like();
      $this-&gt;arrWhere = $this-&gt;get_where();
      $this-&gt;arrWhere['SC.isDeleted'] = 0;
  
      /* for search list */
      if ($this-&gt;countQuery == 1) {
          $this-&gt;db-&gt;from($this-&gt;tableName . ' ' . $this-&gt;alias);
          $this-&gt;countSelectFields = 'COUNT(SC.stock_id) as cnt';
          $result['count'] = $this-&gt;get_count();
      }
  
      $result['resultarr'] = $this-&gt;get_result();
      $result['record_per_page'] = $records_per_page;
  
      return $result;
  }
  </code></pre>
  
  <p>Now I want to add where in to my query and I have tried a few ways but it just does not work.</p>
  
  <p>I am getting confused on to where I am going wrong on such a simple thing. </p>
  
  <p>So I have added a get_wherein function.</p>
  
  <pre><code>function get_wherein() {
    foreach($this-&gt;arrWhereInInputs as $arrWhereInInput) {
        if(isset($this-&gt;$arrWhereInInput) &amp;&amp; $this-&gt;$arrWhereInInput != ''){
          $this-&gt;arrWhereIn[$this-&gt;fieldAlias[$arrWhereInInput].'.'.$arrWhereInInput] = trim($this-&gt;$arrWhereInInput);
        }
      }
      return $this-&gt;arrWhereIn;
  }
  </code></pre>
  
  <p>So I added <code>$this-&gt;arrWhereIn['Field'] = $arr</code> which does not work and also tried to to call <code>$this-&gt;db-&gt;where_in('field',$array)</code> in the select function directly that does not work either. In both the cases it gets ignored and the query is build without the "and where in".</p>
  
  <p>Where am I going wrong and how to build this query?</p>