CodeIgniter Forums
Active Record Class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forum-11.html)
+--- Thread: Active Record Class (/thread-552.html)



Active Record Class - marci - 12-16-2014

Until recently, I've always been able to use the Active Record class to access my databases. Now I have a query with a WHERE clause that looks like this: WHERE item = 1 AND (description LIKE '%keyword%' OR name LIKE '%keyword%'). I'm curious how I would use the where and like functions in the Active Record class to create this clause.
Thanks, Marci


RE: Active Record Class - apparasenal - 12-16-2014

(12-16-2014, 09:30 PM)marci Wrote: Until recently, I've always been able to use the Active Record class to access my databases.  Now I have a query with a WHERE clause that looks like this:  WHERE item = 1 AND (description LIKE '%keyword%' OR name LIKE '%keyword%').  I'm curious how I would use the where and like functions in the Active Record class to create this clause.
Thanks, Marci

Hi,

Try these:

$this->db->where('item', 1);
$this->db->like('description', $keyword);
$this->db->or_like('name', $keyword);