30 lines
756 B
PHP
Executable File
30 lines
756 B
PHP
Executable File
<?php
|
|
|
|
require_once __DIR__ . '/../../connect.php';
|
|
|
|
$driver_id = filterRequest("driver_id");
|
|
|
|
// Prepare the DELETE query
|
|
$sql = "DELETE FROM `car_locations` WHERE driver_id = :driver_id";
|
|
$stmt = $con->prepare($sql);
|
|
|
|
// Bind the driver_id parameter
|
|
$stmt->bindParam(':driver_id', $driver_id, PDO::PARAM_STR);
|
|
|
|
try {
|
|
// Execute the query
|
|
$stmt->execute();
|
|
|
|
if ($stmt->rowCount() > 0) {
|
|
// Success response
|
|
jsonSuccess(null, "Record(s) deleted successfully.");
|
|
} else {
|
|
// Failure response: no records found to delete
|
|
jsonError("No records found for the provided driver ID.");
|
|
}
|
|
} catch (PDOException $e) {
|
|
// Handle any SQL errors
|
|
jsonError("Error deleting records: " . $e->getMessage());
|
|
}
|
|
|
|
?>
|