3
votes

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.?

1
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');Aidas
Perfect... add it as an answer and i'll give you the tick!Tom

1 Answers

9
votes

This should do the trick:

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