From d30fd1a9de80ccb5e0412740ffac0d5fae9e5a21 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Wed, 15 Oct 2014 21:05:38 +0200 Subject: [PATCH] Improved sibling tag order --- src/Dao/TagDao.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Dao/TagDao.php b/src/Dao/TagDao.php index 22f2cb76..bb172e7b 100644 --- a/src/Dao/TagDao.php +++ b/src/Dao/TagDao.php @@ -51,12 +51,13 @@ class TagDao extends AbstractDao implements ICrudDao return []; $tagId = $tag->getId(); $query = $this->fpdo->from($this->tableName) + ->select('COUNT(pt2.postId) AS postCount') ->disableSmartJoin() ->innerJoin('postTags pt1 ON pt1.tagId = tags.id') ->innerJoin('postTags pt2 ON pt2.postId = pt1.postId') ->where('pt2.tagId', $tagId) ->groupBy('tags.id') - ->orderBy('tags.usages DESC, name ASC'); + ->orderBy('postCount DESC, name ASC'); $arrayEntities = iterator_to_array($query); return $this->arrayToEntities($arrayEntities); }