<?php
$db_host = 'localhost';
$db_name = 'transubd_PointageBus';
$db_user = 'transubd_transub_user';
$db_pass = 'Tr@nsub2@24';

$conn = new PDO("mysql:host=$db_host;dbname=$db_name", $db_user, $db_pass);

$sql = "SELECT b.id, b.matricule, l.name as ligne_name
FROM buses b
LEFT JOIN lignes l ON b.id_ligne = l.ligne_code
WHERE b.type = 'Bus' AND b.actif = 1
LIMIT 3";

$stmt = $conn->query($sql);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);

header('Content-Type: application/json');
echo json_encode($rows);
