prepare("SELECT COUNT(*) c FROM articles WHERE status=? AND DATE_FORMAT(created_at,'%Y年%m月')=?"); $st->execute(["published",$ym]); } else { $st = db()->query("SELECT COUNT(*) c FROM articles WHERE status='published'"); } $pg = paginate((int)$st->fetch()["c"], isset($_GET["page"])?(int)$_GET["page"]:1, $perPage); $sql = "SELECT a.*, c.name cat_name FROM articles a LEFT JOIN categories c ON a.category_id=c.id WHERE a.status=? "; $params = ["published"]; if ($ym) { $sql .= "AND DATE_FORMAT(a.created_at,'%Y年%m月')=? "; $params[] = $ym; } $sql .= "ORDER BY a.created_at DESC LIMIT ? OFFSET ?"; $stmt = db()->prepare($sql); $i = 1; foreach ($params as $p) { $stmt->bindValue($i++, $p, PDO::PARAM_STR); } $stmt->bindValue($i++, $pg["perPage"], PDO::PARAM_INT); $stmt->bindValue($i, $pg["offset"], PDO::PARAM_INT); $stmt->execute(); $articles = $stmt->fetchAll(); require_once __DIR__ . "/includes/header.php"; ?>

归档

" href="?ym="> ()
'">
次阅读

1) { ?>