title: Adding brackets to OR_LIKE query on CodeIgniter
body: <p>I have difficulty to adding brackets to my query. My query consists of <code>OR</code>, <code>AND</code> and <code>LIKE</code>. This is my MySQL query:</p>
  
  <pre><code>SELECT * FROM (`vendor`) JOIN `vendor_detail` ON `vendor`.`id_vendor`
  = `vendor_detail`.`id_vendor` JOIN `klasifikasi` ON `vendor_detail`.`id_klasifikasi` = `klasifikasi`.`id_klasifikasi`
  WHERE `vendor_detail`.`id_klasifikasi` = 'K0002' AND
  `vendor`.`st_aktif` = 1 AND (`vendor`.`id_vendor` LIKE '%eka%' OR
  `vendor`.`nama_vendor` LIKE '%eka%' OR `vendor`.`alamat` LIKE '%eka%'
  OR `vendor`.`telp` LIKE '%eka%' OR `vendor`.`mobile` LIKE '%eka%' OR
  `vendor`.`fax` LIKE '%eka%' OR `vendor`.`cp` LIKE '%eka%' OR
  `vendor`.`telp_cp` LIKE '%eka%' OR `vendor`.`catatan` LIKE '%eka%' OR
  `vendor`.`email` LIKE '%eka%')
  </code></pre>
  
  <p>As you can see I am adding brackets after <code>vendor.st_aktif = 1 AND</code> and in the last line of my query.<br>
  How can I implement above query to Code Igniter Active Records?<br>
  This is my current CI AR:</p>
  
  <pre><code>function src_vendor_by_name($src_nama,$src_kls){
      $this-&gt;db-&gt;select('*');
      $this-&gt;db-&gt;from('vendor');
      $this-&gt;db-&gt;join('vendor_detail', 'vendor.id_vendor = vendor_detail.id_vendor');
      $this-&gt;db-&gt;join('klasifikasi', 'vendor_detail.id_klasifikasi = klasifikasi.id_klasifikasi');
      $this-&gt;db-&gt;where('vendor_detail.id_dklasifikasi', $src_kls);
      $this-&gt;db-&gt;where('vendor.st_aktif', 1);
  
      if($src_nama != "")
      { 
          $this-&gt;db-&gt;or_like('vendor.id_vendor',$src_nama);
          $this-&gt;db-&gt;or_like('vendor.nama_vendor',$src_nama);
          $this-&gt;db-&gt;or_like('vendor.alamat',$src_nama);
          $this-&gt;db-&gt;or_like('vendor.telp',$src_nama);
          $this-&gt;db-&gt;or_like('vendor.mobile',$src_nama);
          $this-&gt;db-&gt;or_like('vendor.fax',$src_nama);
          $this-&gt;db-&gt;or_like('vendor.cp',$src_nama);
          $this-&gt;db-&gt;or_like('vendor.telp_cp',$src_nama);
          $this-&gt;db-&gt;or_like('vendor.catatan',$src_nama);
          $this-&gt;db-&gt;or_like('vendor.email',$src_nama);
      }
  
      return $this-&gt;db-&gt;get()-&gt;result_array(); 
  }
  </code></pre>