阅读全文
query("SELECT COUNT(*) c FROM articles WHERE status='published'")->fetch()["c"]; $pg = paginate($total, isset($_GET["page"]) ? (int)$_GET["page"] : 1, $perPage); $stmt = db()->prepare("SELECT a.*, c.name cat_name FROM articles a LEFT JOIN categories c ON a.category_id=c.id WHERE a.status=? ORDER BY a.created_at DESC LIMIT ? OFFSET ?"); $stmt->bindValue(1, "published", PDO::PARAM_STR); $stmt->bindValue(2, $pg["perPage"], PDO::PARAM_INT); $stmt->bindValue(3, $pg["offset"], PDO::PARAM_INT); $stmt->execute(); $articles = $stmt->fetchAll(); ?>
欢迎访问