Fix calcStat for Topic
This commit is contained in:
parent
a2fad121bd
commit
c0d9ebc700
1 changed files with 24 additions and 13 deletions
|
@ -21,22 +21,33 @@ class CalcStat extends Method
|
|||
throw new RuntimeException('The model does not have ID');
|
||||
}
|
||||
|
||||
$vars = [
|
||||
':tid' => $this->model->id
|
||||
];
|
||||
$sql = 'SELECT COUNT(p.id) - 1
|
||||
FROM ::posts AS p
|
||||
WHERE p.topic_id=?i:tid';
|
||||
if ($this->model->moved_to) {
|
||||
$num_replies = 0;
|
||||
$result = [
|
||||
'id' => 0,
|
||||
'poster' => '',
|
||||
'poster_id' => 0,
|
||||
'posted' => 0,
|
||||
'edited' => 0,
|
||||
];
|
||||
} else {
|
||||
$vars = [
|
||||
':tid' => $this->model->id
|
||||
];
|
||||
$sql = 'SELECT COUNT(p.id) - 1
|
||||
FROM ::posts AS p
|
||||
WHERE p.topic_id=?i:tid';
|
||||
|
||||
$num_replies = $this->c->DB->query($sql, $vars)->fetchColumn();
|
||||
$num_replies = $this->c->DB->query($sql, $vars)->fetchColumn();
|
||||
|
||||
$sql = 'SELECT p.id, p.poster, p.poster_id, p.posted, p.edited
|
||||
FROM ::posts AS p
|
||||
WHERE p.topic_id=?i:tid
|
||||
ORDER BY p.id DESC
|
||||
LIMIT 1';
|
||||
$sql = 'SELECT p.id, p.poster, p.poster_id, p.posted, p.edited
|
||||
FROM ::posts AS p
|
||||
WHERE p.topic_id=?i:tid
|
||||
ORDER BY p.id DESC
|
||||
LIMIT 1';
|
||||
|
||||
$result = $this->c->DB->query($sql, $vars)->fetch();
|
||||
$result = $this->c->DB->query($sql, $vars)->fetch();
|
||||
}
|
||||
|
||||
//????
|
||||
$this->model->num_replies = $num_replies;
|
||||
|
|
Loading…
Add table
Reference in a new issue