So I can delete one row using:
$this->db->delete($tableName,array("id"=>4));
...but I can't figure out how to delete multiple rows. I tried:
$this->db->delete($tableName,array("id"=>4,"id"=5));
as well as:
$this->db->delete($tableName,array(array("id"=>4),array("id"=5)));
...but they both don't work. I feel like this should be pretty easy. Any answers?
There is also a very handy keyboard shortcut to delete rows (columns or cells). Press Ctrl + – on the keyboard. That's it! Our blank rows are gone now.
If you want to delete multiple rows or columns at the same time, you can use the Ctrl+Shift+- shortcut. Simply select the rows or columns you want to delete, and then press the Ctrl+Shift+- keys on your keyboard. All of the selected rows and columns will be deleted.
Have you tried this ?
$names = array(4,5);
$this->db->where_in('id', $names);
$this->db->delete('mytable');
not need of associative array.
$ids[] = 1;
$ids[] = 2;
$this->db->where_in( id, $ids );
$this->db->delete('Table_Name');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With