Add offset
This commit is contained in:
parent
26f8c332ef
commit
f9bf65ecb7
|
@ -100,9 +100,10 @@
|
||||||
/**
|
/**
|
||||||
* Retrieve count of images and posts in a thread
|
* Retrieve count of images and posts in a thread
|
||||||
*/
|
*/
|
||||||
private function fetchThreadCount($board, $thread_id) {
|
private function fetchThreadCount($board, $thread_id, $preview_count) {
|
||||||
$query = prepare("SELECT COUNT(NULLIF(TRIM(files), '')) as file_count, COUNT(id) as post_count FROM ``posts_$board`` WHERE `thread` = :id");
|
$query = prepare("SELECT COUNT(NULLIF(TRIM(files), '')) as file_count, COUNT(id) as post_count FROM ``posts_$board`` WHERE `thread` = :id ORDER BY `time` DESC OFFSET :offset");
|
||||||
$query->bindValue(':id', $thread_id, PDO::PARAM_INT);
|
$query->bindValue(':id', $thread_id, PDO::PARAM_INT);
|
||||||
|
$query->bindValue(':offset', $preview_count, PDO::PARAM_INT);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
return $query->fetch(PDO::FETCH_ASSOC);
|
return $query->fetch(PDO::FETCH_ASSOC);
|
||||||
|
@ -155,7 +156,7 @@
|
||||||
$thread->add(new Post($reply, $mod ? '?/' : $config['root'], $mod));
|
$thread->add(new Post($reply, $mod ? '?/' : $config['root'], $mod));
|
||||||
}
|
}
|
||||||
|
|
||||||
$threadCount = $this->fetchThreadCount($post['board'], $post['id']);
|
$threadCount = $this->fetchThreadCount($post['board'], $post['id'], $preview_count);
|
||||||
$thread->omitted = $threadCount['post_count'];
|
$thread->omitted = $threadCount['post_count'];
|
||||||
$thread->omitted_images = $threadCount['file_count'];
|
$thread->omitted_images = $threadCount['file_count'];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue