title: Codeigniter active records: like and where in SQL statement
body: <p>I need to select several rows that respect these conditions:</p>
  
  <ol>
  <li>date >= today</li>
  <li>keyword present in fields 1, 2 or 3</li>
  </ol>
  
  <p>i guess the SQL statement for this should be:</p>
  
  <pre><code>SELECT * FROM `events` WHERE date &gt;= '2010-09-12' AND (field1 LIKE '%keyword%' OR field2 LIKE '%keyword%' OR field3 LIKE '%keyword%')
  </code></pre>
  
  <p>I am trying to write this using codeigniter's active records, but the the LIKE condition seems to override the date one.</p>
  
  <pre><code>$this-&gt;db-&gt;select('*');
  $this-&gt;db-&gt;join('venues', 'events.venue = venue_id');
  
  //first condition: date &gt;= today
  $this-&gt;db-&gt;where('date &gt;=', date('Y-m-d'));
  
  if ($keyword)
  //if keyword is present, add this condition as well
  {
      $this-&gt;db-&gt;like('events.description', $keyword);
      $this-&gt;db-&gt;or_like('band', $keyword);
      $this-&gt;db-&gt;or_like('venues.venue', $keyword);
  }
  
  $this-&gt;db-&gt;order_by('date', 'ASC');
  $this-&gt;db-&gt;order_by('events.priority', 'DESC'); 
  $Q = $this-&gt;db-&gt;get('events');
  </code></pre>
  
  <p>I probably need to insert the LIKE statement inside a parentesis, but don't know how to do it.</p>