42 lines
945 B
PHP
42 lines
945 B
PHP
<?php
|
|
include "../../connect.php";
|
|
|
|
$driver_id = filterRequest("driver_id");
|
|
|
|
$sql = "SELECT
|
|
car_locations.id,
|
|
car_locations.driver_id,
|
|
car_locations.latitude,
|
|
car_locations.longitude,
|
|
car_locations.heading,
|
|
car_locations.speed,
|
|
car_locations.`status`,
|
|
car_locations.created_at,
|
|
car_locations.updated_at,
|
|
`driver`.`gender`,
|
|
CarRegistration.model
|
|
FROM
|
|
car_locations
|
|
LEFT JOIN `driver` ON `driver`.`id` = car_locations.driver_id
|
|
LEFT JOIN `CarRegistration`
|
|
ON `CarRegistration`.`driverID` = CarRegistration.driverID
|
|
WHERE
|
|
driver_id = '$driver_id'
|
|
ORDER BY
|
|
created_at
|
|
DESC
|
|
LIMIT 1;";
|
|
|
|
$stmt = $con->prepare($sql);
|
|
$stmt->execute();
|
|
$car_locations = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if ($car_locations) {
|
|
// Print the car location data as JSON
|
|
printSuccess($data = $car_locations);
|
|
} else {
|
|
// Print a failure message
|
|
printFailure($message = "No car locations found");
|
|
}
|
|
|
|
?>
|