From 904b8b1f503468bf8672fa402a9b999b1691d02c Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Thu, 7 Jul 2022 10:38:53 -0500 Subject: [PATCH] Tweak SQL to use 'using' instead of 'on' --- lib/NewsletterSubscription.php | 2 +- lib/Patron.php | 2 +- www/about/index.php | 2 +- www/webhooks/postmark.php | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/NewsletterSubscription.php b/lib/NewsletterSubscription.php index 46e75094..7e648e8c 100644 --- a/lib/NewsletterSubscription.php +++ b/lib/NewsletterSubscription.php @@ -112,7 +112,7 @@ class NewsletterSubscription extends PropertiesBase{ // *********** public static function Get(string $uuid): NewsletterSubscription{ - $result = Db::Query('SELECT ns.* from NewsletterSubscriptions ns inner join Users u on ns.UserId = u.UserId where u.Uuid = ?', [$uuid], 'NewsletterSubscription'); + $result = Db::Query('SELECT ns.* from NewsletterSubscriptions ns inner join Users u using(UserId) where u.Uuid = ?', [$uuid], 'NewsletterSubscription'); if(sizeof($result) == 0){ throw new Exceptions\InvalidNewsletterSubscriptionException(); diff --git a/lib/Patron.php b/lib/Patron.php index f6d65296..973ccb6b 100644 --- a/lib/Patron.php +++ b/lib/Patron.php @@ -59,7 +59,7 @@ class Patron extends PropertiesBase{ } public static function GetByEmail(?string $email): Patron{ - $result = Db::Query('SELECT p.* from Patrons p inner join Users u on p.UserId = u.UserId where u.Email = ?', [$email], 'Patron'); + $result = Db::Query('SELECT p.* from Patrons p inner join Users u using(UserId) where u.Email = ?', [$email], 'Patron'); if(sizeof($result) == 0){ throw new Exceptions\InvalidPatronException(); diff --git a/www/about/index.php b/www/about/index.php index a960c617..c19df141 100644 --- a/www/about/index.php +++ b/www/about/index.php @@ -9,7 +9,7 @@ $anonymousPatronCount = 0; $patronsCircle = Db::Query('SELECT if(p.AlternateName is not null, p.AlternateName, u.Name) as SortedName from Patrons p inner join Users u - on p.UserId = u.UserId + using(UserId) where p.IsAnonymous = false and p.Ended is null diff --git a/www/webhooks/postmark.php b/www/webhooks/postmark.php index 23140e6c..a315dbf7 100644 --- a/www/webhooks/postmark.php +++ b/www/webhooks/postmark.php @@ -36,7 +36,7 @@ try{ // Received when a user marks an email as spam $log->Write('Event type: spam complaint.'); - Db::Query('DELETE ns.* from NewsletterSubscriptions ns inner join Users u on ns.UserId = u.UserId where u.Email = ?', [$post->Email]); + Db::Query('DELETE ns.* from NewsletterSubscriptions ns inner join Users u using(UserId) where u.Email = ?', [$post->Email]); } elseif($post->RecordType == 'SubscriptionChange' && $post->SuppressSending){ // Received when a user clicks Postmark's "Unsubscribe" link in a newsletter email @@ -45,7 +45,7 @@ try{ $email = $post->Recipient; // Remove the email from our newsletter list - Db::Query('DELETE ns.* from NewsletterSubscriptions ns inner join Users u on ns.UserId = u.UserId where u.Email = ?', [$email]); + Db::Query('DELETE ns.* from NewsletterSubscriptions ns inner join Users u using(UserId) where u.Email = ?', [$email]); // Remove the suppression from Postmark, since we deleted it from our own list we will never email them again anyway $handle = curl_init();