title: How to group WHERE clauses with active record?
body: <p>The below active record code isn't grouping WHERE clauses like I need it to...</p>
  
  <pre><code>        $this-&gt;db-&gt;where('customers_id',$this-&gt;user-&gt;getCurrentUserProperty('id'))
          $this-&gt;db-&gt;like('delivery_name', $this-&gt;input-&gt;post('search'));
          $this-&gt;db-&gt;or_like('customers_company', $this-&gt;input-&gt;post('search'));
          $this-&gt;db-&gt;or_like('customers_company2', $this-&gt;input-&gt;post('search'));
          $this-&gt;db-&gt;or_like('customers_company3', $this-&gt;input-&gt;post('search'));
          $this-&gt;db-&gt;or_like('customers_company4', $this-&gt;input-&gt;post('search'));
  </code></pre>
  
  <p>This generates</p>
  
  <pre><code>WHERE `customers_id` = 31509 AND `delivery_name` LIKE '%str%' OR `customers_company` LIKE '%str%'"
  </code></pre>
  
  <p>I NEED the output to have parenthesis around it like below... how can I do that?</p>
  
  <pre><code>WHERE `customers_id` = 31509 AND (`delivery_name` LIKE '%str%' OR `customers_company` LIKE '%str%')"
  </code></pre>
  
  <p>Note: I hate active record for annoying times like this</p>
  
  <p>If I use the below method, how can I sanitize the input so it's not raw into the query?</p>
  
  <pre><code>$where = "name='Joe' AND status='boss' OR status='active'";
  
  $this-&gt;db-&gt;where($where);
  </code></pre>