[web-master] improve-notes-removing-speed: Use prepared queries for loop
| From: | Derick Rethans | Date: | Mon, 02 Sep 2024 12:51:20 +0000 |
| Subject: | [web-master] improve-notes-removing-speed: Use prepared queries for loop | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-32046@lists.php.net to get a copy of this message | ||
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("phpdoc@lists.php.net, php-notes@lists.php.net", "Deleted $count old and low
rated notes", $body, "From: noreply@php.net", "-fnoreply@php.net");