Created
March 28, 2019 17:28
-
-
Save colinvh/485aff5eb3fff7c290e6fda1b2809178 to your computer and use it in GitHub Desktop.
Delete multiple rows by ID with one statement (mysqli)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ids = [1, 2, 3]; | |
$qqq = join(', ', array_fill(0, sizeof($ids), '?')); | |
$iii = str_repeat('i', sizeof($ids)); | |
$stmt = $conn->prepare("DELETE FROM table WHERE id IN ($qqq)"); | |
$args = $ids; | |
array_unshift($args, $iii); | |
call_user_func_array([$stmt, 'bind_param'], $args); | |
$stmt->execute(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment