Skip to content

Commit

Permalink
Fix post visits was shown instead of topic visits
Browse files Browse the repository at this point in the history
  • Loading branch information
blackcoder87 committed Sep 8, 2020
1 parent cfee624 commit 0f15f59
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions application/modules/forum/mappers/Topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Topic extends \Ilch\Mapper
{
public function getTopicsByForumId($id, $pagination = NULL)
{
$sql = 'SELECT SQL_CALC_FOUND_ROWS *, topics.id, MAX(posts.date_created) AS latest_post
$sql = 'SELECT SQL_CALC_FOUND_ROWS *, topics.id, topics.visits, MAX(posts.date_created) AS latest_post
FROM `[prefix]_forum_topics` AS topics
LEFT JOIN `[prefix]_forum_posts` AS posts ON topics.id = posts.topic_id
WHERE topics.forum_id = '.(int)$id.'
Expand All @@ -24,18 +24,18 @@ public function getTopicsByForumId($id, $pagination = NULL)

if (!empty($pagination)) {
$sql .= ' LIMIT '.implode(',',$pagination->getLimit());
$fileArray = $this->db()->queryArray($sql);
$topicArray = $this->db()->queryArray($sql);
$pagination->setRows($this->db()->querycell('SELECT FOUND_ROWS()'));
} else {
$fileArray = $this->db()->queryArray($sql);
$topicArray = $this->db()->queryArray($sql);
}

$entry = [];
$user = null;
$dummyUser = null;
$userCache = [];

foreach ($fileArray as $entries) {
foreach ($topicArray as $entries) {
$entryModel = new TopicModel();
$userMapper = new UserMapper();
$entryModel->setId($entries['id']);
Expand Down

0 comments on commit 0f15f59

Please sign in to comment.