Author: Derick Rethans (derickr)
Date: 2024-09-02T13:51:04+01:00
Commit: Use prepared queries for loop · php/web-master@d609ede · GitHub
Raw diff: https://github.com/php/web-master/commit/d609edeb1ecef9f761b8407b29a5c243ce42ea0a.diff
Use prepared queries for loop
Changed paths:
M scripts/remove-low-rated-notes
Diff:
diff --git a/scripts/remove-low-rated-notes b/scripts/remove-low-rated-notes
index ef66988..3b05b4f 100755
--- a/scripts/remove-low-rated-notes
+++ b/scripts/remove-low-rated-notes
@@ -34,9 +34,9 @@ $body = "Following were the {$count} notes with a rating less than " . RATING_TH
. sprintf("These notes represented %.1f%% of the %d total user notes,\nand have now been removed.\n\n", ($count / $total) * 100, $total)
. $table;
+$stmt = $pdo->prepare("DELETE FROM note WHERE id = ?");
foreach ($noteIDs as $noteID) {
- $query = "DELETE FROM note WHERE id = ?";
- $result = $pdo->safeQuery($query, [ $noteID ]);
+ $result = $stmt->execute([ $noteID ]);
}
mail("phpdoc@lists.php.net, php-notes@lists.php.net", "Deleted $count old and low rated notes", $body, "From: noreply@php.net", "-fnoreply@php.net");