From 14ddf26b4219d97f9c4ba36800641da0d29cb698 Mon Sep 17 00:00:00 2001 From: Roman Parpalak Date: Fri, 10 May 2024 15:29:52 +0300 Subject: [PATCH] Fixed 'column "count" does not exist' in postgres. --- _include/src/Model/TagsProvider.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/_include/src/Model/TagsProvider.php b/_include/src/Model/TagsProvider.php index 0293c59..254ccbe 100644 --- a/_include/src/Model/TagsProvider.php +++ b/_include/src/Model/TagsProvider.php @@ -23,8 +23,11 @@ public function __construct( ) { } - - // Makes tags list for the tags page and the placeholder + /** + * Makes tags list for the tags page and the placeholder + * + * @throws \S2\Cms\Pdo\DbLayerException + */ public function tagsList(): array { if ($this->cachedTags === null) { @@ -43,17 +46,18 @@ public function tagsList(): array $query = [ 'SELECT' => 'tag_id, name, url, (' . $this->dbLayer->build($subQuery) . ') AS count', 'FROM' => 'tags AS t', - 'HAVING' => 'count > 0', 'ORDER BY' => 'count DESC', ]; $result = $this->dbLayer->buildAndQuery($query); while ($row = $this->dbLayer->fetchAssoc($result)) { - $this->cachedTags[] = array( - 'title' => $row['name'], - 'link' => $this->urlBuilder->link('/' . $this->tagsUrl . '/' . urlencode($row['url']) . '/'), - 'num' => $row['count'], - ); + if ($row['count'] > 0) { + $this->cachedTags[] = array( + 'title' => $row['name'], + 'link' => $this->urlBuilder->link('/' . $this->tagsUrl . '/' . urlencode($row['url']) . '/'), + 'num' => $row['count'], + ); + } } }