php - MySQL update multiple rows at once using parameter binding
one text
I passing an array of ID's to a php file that are IDs that should be updated. So far, checking SO I see that to update multiple values the following query must be used:
UPDATE employees SET gender = 'Male' WHERE id IN (1,2,3)
However, I think to avoid sql injections, I'm trying to code it as follows:
$arr = [1,2,4];
$stmt = $conn->prepare("UPDATE employees SET gender = 'Male' WHERE id IN (?)")
$stmt->bindValue(1, $arr);
Query executes apparently with no errors, but rows are not updating.
Source