Codeigniter grouping OR conditions using active record database library


/ Published in: PHP
Save to your folder(s)

when someone trying to or two conditions using active record database library in codeigniter


Copy this code and paste it in your HTML
  1. $this->db->from('posts');
  2.  
  3. $this->db->where('id', $id);
  4. $this->db->where('(`title` LIKE \'%'.$title.'%\' OR `body` LIKE \'%'.$body.'%\' OR `author` LIKE \'%'.$author.'%\')', NULL, FALSE);
  5.  
  6. // Query:
  7.  
  8. // SELECT * FROM (`posts`) WHERE (`title` LIKE '%ach%' OR `text` LIKE '%ach%' OR `author` LIKE '%ach%') AND `id` = '12'

URL: http://pvibeesh.wordpress.com/2009/02/13/codeigniter-grouping-or-conditions-using-active-record-database-library/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.