3

I have found this codeigniter active record query where I can delete items in an array

$this->db->delete('stack', array('id' => $id)) 

However, I would like to delete items which are not in the array.

Is this possible.?

2
  • 2
    I don't have a chance to test it, but would that not work: $this->db->where_not_in('id', $ids); $this->db->delete('stack'); Commented Apr 1, 2014 at 15:36
  • Perfect... add it as an answer and i'll give you the tick! Commented Apr 1, 2014 at 16:27

1 Answer 1

9

This should do the trick:

$this->db->where_not_in('id', $ids);
$this->db->delete('stack'); 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.