Welcome Guest, Not a member yet? Register   Sign In
"where_not_in" -- Am I an idiot?

[eluser]Daniel Walton[/eluser]
Hi, i'm using the active record class as such:

$this->db->where_not_in('id', $id);



Which should be excluding that particular ID from the result, right? Wrong - all ids are coming back Sad What could be wrong?

Is it because you need to pass it an array as the second value (even if the array only holds one value)?

[eluser]Daniel Walton[/eluser]
Ahh, my bad. Knew it had to be something simple.


[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:

$this->db->where('id !=', $id);

// or

$this->db->where_not_in('id', array($id));

In this example, the first would make more sense.

[eluser]Daniel Walton[/eluser]
Yup yup, made a simple is_array() check in my application now to call either or.

Theme © iAndrew 2016 - Forum software by © MyBB