title: Cleanest way to put condition inside CodeIgniter ActiveRecord
body: <p>I need to put condition inside CodeIgniter ActiveRecord, here's my code:</p>
  
  <pre><code>public function getData($numb, $period, $status){
      $this-&gt;db-&gt;select("COUNT(*) AS jml")
               -&gt;from()
               -&gt;where_not_in();
               if($status !== 'all'){
                  $this-&gt;db-&gt;where("LAYANAN.TGL_LAYANAN BETWEEN DATEADD(" . $period ."," . $numb .", GETDATE()) AND GETDATE()");
               }
               $this-&gt;db-&gt;where_in()
               -&gt;group_by("");
      return $query = $this-&gt;db-&gt;get();
  }
  </code></pre>
  
  <p>I also need to put <code>$period</code> and <code>$numb</code> variables inside <code>where</code> statement. It works, but I don't really like how my code looks like. It looks so dirty. Can you guys give me solution in order to achieve cleaner code? Thanks</p>