19 lines
549 B
PHP
19 lines
549 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
require_once __DIR__ . '/../includes/bootstrap.php';
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
$conversationId = (int)($_GET['conversation_id'] ?? 0);
|
|
if ($conversationId <= 0) {
|
|
echo json_encode(['items' => []]);
|
|
exit;
|
|
}
|
|
|
|
$stmt = db()->prepare("SELECT id, direction, body, status, created_at FROM messages WHERE conversation_id = :cid ORDER BY created_at ASC");
|
|
$stmt->bindValue(':cid', $conversationId, PDO::PARAM_INT);
|
|
$stmt->execute();
|
|
$items = $stmt->fetchAll();
|
|
|
|
echo json_encode(['items' => $items]);
|