IF I want to add ( ) between condition, How I can do this? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: IF I want to add ( ) between condition, How I can do this? (/showthread.php?tid=57714) |
IF I want to add ( ) between condition, How I can do this? - El Forum - 04-04-2013 [eluser]Unknown[/eluser] I use CI Active Database to select data from condition below Code: $this->select()->from('table')->where('fieldA != "dataA1"')->like('fieldB', $input)->or_like('fieldC',$input); but I want to Add (), becuase I don't want to show some data from first condition, but still show. how I can do that IF I want to add ( ) between condition, How I can do this? - El Forum - 04-05-2013 [eluser]pickupman[/eluser] Perhaps posting how you want the parenthesis to look in your final query would be helpful. What statements are you wanting to be inside of the parenthesis? IF I want to add ( ) between condition, How I can do this? - El Forum - 06-06-2013 [eluser]Unknown[/eluser] [quote author="pickupman" date="1365194488"]What statements are you wanting to be inside of the parenthesis?[/quote] As I understand it he is interested in how to create the following query: Code: SELECT * FROM table WHERE fieldA != "dataA1" AND ("fieldB" LIKE '%$input%' OR "fieldC" LIKE '%$input%'); IF I want to add ( ) between condition, How I can do this? - El Forum - 06-07-2013 [eluser]Pert[/eluser] At the moment there is no way to add brackets in Active Records. The closest you can do is Code: $this->db->where('(table_a.col_a = \'a\' OR table_b.col_b = \'b\')', null, false); You have to remember to escape your values manually. IF I want to add ( ) between condition, How I can do this? - El Forum - 06-07-2013 [eluser]jairoh_[/eluser] u can use query bindings |