Posted By

pruntrut on 06/15/12


Tagged

php codeigniter


Versions (?)

Codeigniter grouping OR conditions using active record database library


 / Published in: PHP
 

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

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

  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'

Report this snippet  

You need to login to post a comment.