query("SELECT COUNT(*) FROM articles")->fetchColumn(); $pages = max(1,(int)ceil($total/$per)); $page = min($page,$pages); $off = ($page-1)*$per; $stmt = db()->prepare("SELECT a.id,a.title,a.views,a.created_at,c.name AS cat, COUNT(t.id) AS tagcount FROM articles a LEFT JOIN categories c ON a.category_id=c.id LEFT JOIN article_tags at ON at.article_id=a.id LEFT JOIN tags t ON t.id=at.tag_id GROUP BY a.id ORDER BY a.created_at DESC LIMIT ? OFFSET ?"); $stmt->bindValue(1,$per,PDO::PARAM_INT); $stmt->bindValue(2,$off,PDO::PARAM_INT); $stmt->execute(); $list = $stmt->fetchAll(); ?>
| ID | 标题 | 分类 | 标签 | 阅读 | 日期 | 操作 |
|---|---|---|---|---|---|---|
| 暂无文章 | ||||||