ez-api/includes/public/home.php
2024-11-02 12:58:24 +08:00

9 lines
288 B
PHP

<?php
$sql = "SELECT id, title, content, DATE_FORMAT(created_at, '%Y-%m-%d') AS created_at, type
FROM articles
ORDER BY created_at DESC";
$stmt = $pdo->query($sql);
$articles = $stmt->fetchAll();
echo json_encode($articles, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
?>