codeigniter query problem - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: codeigniter query problem (/showthread.php?tid=57015) |
codeigniter query problem - El Forum - 02-07-2013 [eluser]Bigil Michael[/eluser] my code Code: function lekhanam($lekhanam) { so i print the query Code: SELECT `a`.*, `ac`.`category_name`, `at`.`id` as author_id, `at`.`name`, `at`.`photo` as authorimage FROM (`articles` AS a) JOIN `article_categories` AS ac ON `ac`.`category_id` = `a`.`category_id` JOIN `authors` AS at ON `at`.`id` = `a`.`author_id` WHERE `a`.`id` = '7' OR `a`.`id` = '8' OR `a`.`id` = '9' OR `a`.`id` = '10' OR `a`.`id` = '11' AND `a`.`status` = 1 AND `at`.`status` = 1 LIMIT 5 Code: SELECT `a`.*, `ac`.`category_name`, `at`.`id` as author_id, `at`.`name`, `at`.`photo` as authorimage FROM (`articles` AS a) JOIN `article_categories` AS ac ON `ac`.`category_id` = `a`.`category_id` JOIN `authors` AS at ON `at`.`id` = `a`.`author_id` WHERE (`a`.`id` = '7' OR `a`.`id` = '8' OR `a`.`id` = '9' OR `a`.`id` = '10' OR `a`.`id` = '11') AND `a`.`status` = 1 AND `at`.`status` = 1 LIMIT 5 It runs fine . I dont know how to put a bracket in codeigniter query. can any one modify this query.. thanks ... codeigniter query problem - El Forum - 02-07-2013 [eluser]Bigil Michael[/eluser] can any one solve this issue????????? codeigniter query problem - El Forum - 02-07-2013 [eluser]Aken[/eluser] You have three options: 1) Write the entire query manually. 2) Write the whole OR block of your where (everything between the parentheses) as one $this->db->where() call. 3) Use the 3.0 development version of CI, that supports grouping where() clauses. codeigniter query problem - El Forum - 02-08-2013 [eluser]Bigil Michael[/eluser] thanks for your reply. solved my problem like this way Code: function lekhanam($lekhanam) { codeigniter query problem - El Forum - 02-10-2013 [eluser]rjsmith[/eluser] why not use 'IN' instead of multiple 'OR' |