![]() |
Writing a for loop in Active Record (4 lines) - 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: Writing a for loop in Active Record (4 lines) (/showthread.php?tid=58000) |
Writing a for loop in Active Record (4 lines) - El Forum - 05-04-2013 [eluser]alvaroeesti[/eluser] Hello, The problem that I am having is in translating the Loop, so that it renders this syntax Code: AND (`x`.`id` = '37' OR `x`.`id` = '31' OR `x`.`id` = '36') being x the city table. And here is the active record. Code: $this->db->select('asset_id, region_name, etc etc); I need to equal it like I said, to this sql rendering Code: AND (`x`.`id` = '37' OR `x`.`id` = '31' OR `x`.`id` = '36') Code: AND `x`.`id` = '31' which is not quite the same, because of the parentheses etc Writing a for loop in Active Record (4 lines) - El Forum - 05-04-2013 [eluser]TheFuzzy0ne[/eluser] I think WHERE IN would be more suitable: Code: $this->db->from('asset a') Writing a for loop in Active Record (4 lines) - El Forum - 05-04-2013 [eluser]alvaroeesti[/eluser] Look at that!! awesome man! I have been a full day wrestling because I did not know that such where_in existed in active record, (giving me lots of dead times not making progresses) that was such a straightforward solution! bless you man! I m trying to finish the web and when I do, and get it working I ll definitively need someone who takes it from there and adds more stuff. I check your web now, kind regards and thank you very much Álvaro |