$ids = $_POST['ids'];
// sky***earth***sea***sun***...
$ids = explode("***", $ids);
foreach ($ids as $id) {
$st = $db->query("delete from tags where id = " . $id);
}
Is there a more elegant way to delete multiple rows, especially regarding peformances in case of huge array? Something like:
$st = $db->query("delete from tags where id in " . $ids);
Any suggestion?
id
is a text column i.e.sky
,earth
etc Then the$id
needs to be wrapped in quotes like$st = $db->query("delete from tags where id = '$id' ");
But do pay heed to the SQL Injection Attack Even if you are escaping inputs, its not safe! Use prepared parameterized statements in either theMYSQLI_
orPDO
API's – RiggsFolly 11 hours ago