<?php
//getRideStatusBegin.php
require_once __DIR__ . '/../../connect.php';

$ride_id = filterRequest("ride_id");

if (empty($ride_id)) {
    jsonError("Ride ID is missing.");
    exit;
}

$sql = "SELECT `status`, `DriverIsGoingToPassenger`, `rideTimeStart` FROM `ride` WHERE `id` = :ride_id";
$stmt = $con->prepare($sql);
$stmt->bindParam(':ride_id', $ride_id, PDO::PARAM_INT);
$stmt->execute();

$row = $stmt->fetch(PDO::FETCH_ASSOC);

if ($row) {
    echo json_encode([
        "status" => "success",
        "data" => $row
    ]);
} else {
    jsonError("Ride not found.");
}
?>