Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 904
Tom Avatar asked Nov 23 '25 19:11

Tom


1 Answers

This should do the trick:

$this->db->where_not_in('id', $ids);
$this->db->delete('stack'); 
like image 171
Aidas Avatar answered Nov 26 '25 10:11

Aidas