"where_not_in" -- Am I an idiot? - 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: "where_not_in" -- Am I an idiot? (/showthread.php?tid=12014) |
"where_not_in" -- Am I an idiot? - El Forum - 10-02-2008 [eluser]Daniel Walton[/eluser] Hi, i'm using the active record class as such: Code: $this->db->where_not_in('id', $id); ... Code: $this->db->get('the_table'); Which should be excluding that particular ID from the result, right? Wrong - all ids are coming back What could be wrong? "where_not_in" -- Am I an idiot? - El Forum - 10-02-2008 [eluser]johnwbaxter[/eluser] Is it because you need to pass it an array as the second value (even if the array only holds one value)? "where_not_in" -- Am I an idiot? - El Forum - 10-02-2008 [eluser]Daniel Walton[/eluser] Ahh, my bad. Knew it had to be something simple. /Thx "where_not_in" -- Am I an idiot? - El Forum - 10-02-2008 [eluser]Phil Sturgeon[/eluser] audiopleb is right. where_not_in() in used to create SQL such as WHERE id NOT IN('2', '42', '35') etc. You need to either use: Code: $this->db->where('id !=', $id); In this example, the first would make more sense. "where_not_in" -- Am I an idiot? - El Forum - 10-02-2008 [eluser]Daniel Walton[/eluser] Yup yup, made a simple is_array() check in my application now to call either or. |