Files
Siro/backend/ride/location/getLatestLocationPassenger.php
2026-06-09 08:40:31 +03:00

29 lines
539 B
PHP

<?php
require_once __DIR__ . '/../../connect.php';
$rideId = filterRequest("rideId");
$sql = "SELECT
*
FROM
`passengerlocation` pl
WHERE
pl.rideId = :rideId
ORDER BY
pl.createdAt
DESC
LIMIT 1";
$stmt = $con->prepare($sql);
$stmt->execute([':rideId' => $rideId]);
$car_locations = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($car_locations) {
// Print the car location data as JSON
jsonSuccess($data = $car_locations);
} else {
// Print a failure message
jsonError($message = "No car locations found");
}
?>