Author: Derick Rethans (derickr)
Date: 2024-09-02T12:51:07Z

Commit: 
https://github.com/php/web-master/commit/72a3ab1a2c352006c3befa8ba47700bb2b0dd58a
Raw diff: 
https://github.com/php/web-master/commit/72a3ab1a2c352006c3befa8ba47700bb2b0dd58a.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("php...@lists.php.net, php-no...@lists.php.net", "Deleted $count old and 
low rated notes", $body, "From: nore...@php.net", "-fnore...@php.net");

Reply via email to