我正在尝试获取一组 ID 号并使用该 ID 号更新每一行。PHP PDO 代码如下:
private function markAsDelivered($ids) {
$update = $this->dbh->prepare("
UPDATE notifications
SET notified = 1
WHERE notification_id IN (
:ids
)
");
$ids = join(',', $ids);
Logger::log("Marking the following as delivered: " . $ids, $this->dbh);
$update->bindParam(":ids", $ids, PDO::PARAM_STR);
$update->execute();
}
然而,当它运行时,只有列表中的第一项得到更新,尽管记录了多个 ID 号。如何修改它以更新多行?