Tom
Tom

Reputation: 12998

Codeigniter Active Record - Delete where not in array

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

Upvotes: 3

Views: 11682

Answers (1)

Aidas
Aidas

Reputation: 1249

This should do the trick:

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

Upvotes: 9

Related Questions