I have a function where i delete multiple rows in a database using foreach loops.
Here is the code below.
$ids = array(1, 3, 7, 8, 9, 32);
foreach ($ids as $id) {
$sql = mysql->query("DELETE FROM tablename WHERE id = '$id' " );
}
This works in deleting all the rows that had the ids in the array, but my question is, how effective can this be especially if the ids are over 2000, can such looping handle over thousands of ids in an array without affecting the database? Or is there a better way of handling this?