Files
Siro/backend/ride/notificationCaptain/deleteAvailableRide.php
2026-06-16 17:47:19 +03:00

32 lines
985 B
PHP

<?php
require_once __DIR__ . '/../../connect.php';
try {
// Retrieve and validate the 'id' parameter
$id = filterRequest('id');
if ($id === null || $id === '') {
throw new Exception("Missing required parameter: id");
}
// Prepare the SQL query to delete the record
$sql = "DELETE FROM `waitingRides` WHERE `id` = :id";
// Prepare and execute the statement
$stmt = $con->prepare($sql);
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
$stmt->execute();
// Check the result and print the appropriate message
if ($stmt->rowCount() > 0) {
jsonSuccess(null, "Record with ID $id deleted successfully.");
} else {
jsonError("No record found with ID $id.");
}
} catch (PDOException $e) {
error_log("[deleteAvailableRide/PDO] " . $e->getMessage());
jsonError("Database error");
} catch (Exception $e) {
error_log("[deleteAvailableRide] " . $e->getMessage());
jsonError("Error deleting ride");
}
?>