Posted by: pvibeesh on: February 13, 2009
when someone trying to or two conditions using active record database library in codeigniter
Eg:
$this->db->from('posts');
$this->db->where('id', $id);
$this->db->like('title', $title);
$this->db->like('body', $body);
$this->db->or_like('author', $author);
You can do it like this
$this->db->from('posts');
$this->db->where('id', $id);
$this->db->where('(`title` LIKE \'%'.$title.'%\' OR `body` LIKE \'%'.$body.'%\' OR `author` LIKE \'%'.$author.'%\')', NULL, FALSE);
// Query:
// SELECT * FROM (`posts`) WHERE (`title` LIKE '%ach%' OR `text` LIKE '%ach%' OR `author` LIKE '%ach%') AND `id` = '12'
October 31, 2009 at 6:38 am
thanks man