prepare('SELECT COUNT(*) FROM threads' . $wsql); $stc->execute($args); $total = (int)$stc->fetchColumn(); $pageSize = max(5, (int)fb_cfg('page_size', 20)); $pages = max(1, (int)ceil($total / $pageSize)); $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; if ($page < 1) { $page = 1; } if ($page > $pages){ $page = $pages; } $offset = ($page - 1) * $pageSize; $sql = 'SELECT id, title, category, status, author_name, reply_count, created_at, updated_at,' . ' substr(body, 1, 300) AS excerpt FROM threads' . $wsql . ' ORDER BY ' . $order . ' LIMIT ' . $pageSize . ' OFFSET ' . $offset; $sth = $pdo->prepare($sql); $sth->execute($args); $threads = $sth->fetchAll(); // 附件缩略图与数量(只在有附件时才有开销) $tids = []; foreach ($threads as $t) { $tids[] = (int)$t['id']; } $attImgs = $tids ? fb_attach_map_images($pdo, $tids, 3) : []; $attCount = $tids ? fb_attach_count_map($pdo, $tids) : []; fb_layout_head('全部问题'); ?>