Browse Source

Be explicit when id column is ambiguous

Théophile Helleboid - chtitux 1 year ago
parent
commit
c70dc852a1
2 changed files with 4 additions and 4 deletions
  1. 1 1
      classes/ccache.php
  2. 3 3
      classes/counters.php

+ 1 - 1
classes/ccache.php

@@ -141,7 +141,7 @@ class CCache {
 
 			$sth = $pdo->prepare("SELECT SUM(value) AS sv
 				FROM ttrss_counters_cache, ttrss_feeds
-				WHERE id = feed_id AND
+				WHERE ttrss_feeds.id = feed_id AND
 				(cat_id = :cat OR (:cat = 0 AND cat_id IS NULL)) AND
 				ttrss_counters_cache.owner_uid = :uid AND
 				ttrss_feeds.owner_uid = :uid");

+ 3 - 3
classes/counters.php

@@ -24,11 +24,11 @@ class Counters {
 
 		$pdo = DB::pdo();
 
-		$sth = $pdo->prepare("SELECT id AS cat_id, value AS unread,
+		$sth = $pdo->prepare("SELECT ttrss_feed_categories.id AS cat_id, value AS unread,
 			(SELECT COUNT(id) FROM ttrss_feed_categories AS c2
 				WHERE c2.parent_cat = ttrss_feed_categories.id) AS num_children
 			FROM ttrss_feed_categories, ttrss_cat_counters_cache
-			WHERE ttrss_cat_counters_cache.feed_id = id AND
+			WHERE ttrss_cat_counters_cache.feed_id = ttrss_feed_categories.id AND
 			ttrss_cat_counters_cache.owner_uid = ttrss_feed_categories.owner_uid AND
 			ttrss_feed_categories.owner_uid = ?");
 		$sth->execute([$_SESSION['uid']]);
@@ -172,7 +172,7 @@ class Counters {
 			FROM ttrss_feeds, ttrss_counters_cache
 			WHERE ttrss_feeds.owner_uid = ?
 				AND ttrss_counters_cache.owner_uid = ttrss_feeds.owner_uid
-				AND ttrss_counters_cache.feed_id = id");
+				AND ttrss_counters_cache.feed_id = ttrss_feeds.id");
 		$sth->execute([$_SESSION['uid']]);
 
 		while ($line = $sth->fetch()) {