Fix for sql_mode=only_full_group_by

In MySQL 5.7, the default is sql_mode=only_full_group_by
This commit is contained in:
Visman 2019-12-21 00:44:24 +07:00
parent 2cdcd19568
commit 5aca7b110d

View file

@ -297,14 +297,14 @@ class Model extends DataModel
':tid' => $this->id,
':pid' => $pid,
];
$sql = 'SELECT COUNT(p.id) AS num, j.id AS flag
$sql = 'SELECT COUNT(p.id) AS num
FROM ::posts AS p
INNER JOIN ::posts AS j ON (j.topic_id=?i:tid AND j.id=?i:pid)
WHERE p.topic_id=?i:tid AND p.id<?i:pid';
WHERE p.topic_id=?i:tid AND p.id<?i:pid'; //???? может на два запроса разбить?
$result = $this->c->DB->query($sql, $vars)->fetch();
$this->page = empty($result['flag']) ? null : (int) \ceil(($result['num'] + 1) / $this->c->user->disp_posts);
$this->page = empty($result) ? null : (int) \ceil(($result['num'] + 1) / $this->c->user->disp_posts);
}
/**