<?php
require_once "auth.php";
$user = API_AUTH();

$q = $conn->prepare("
    SELECT terminal_id,account_no,default_symbol,last_heartbeat,status
    FROM connections
    WHERE user_id=?
    ORDER BY last_heartbeat DESC
");
$q->bind_param("i", $user['id']);
$q->execute();
$res = $q->get_result();

$data = [];
while($row = $res->fetch_assoc()) $data[] = $row;

echo json_encode($data);
?>
