first commit
This commit is contained in:
39
backend/ride/notificationCaptain/updateWaitingTrip.php
Normal file
39
backend/ride/notificationCaptain/updateWaitingTrip.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../connect.php';
|
||||
|
||||
$id = filterRequest("id");
|
||||
|
||||
$fields = [];
|
||||
$params = [':id' => $id];
|
||||
|
||||
$possibleFields = [
|
||||
'start_location', 'end_location', 'date', 'time', 'price',
|
||||
'passenger_id', 'status', 'carType', 'passengerRate',
|
||||
'price_for_passenger', 'distance', 'duration'
|
||||
];
|
||||
|
||||
foreach ($possibleFields as $field) {
|
||||
if (isset($_POST[$field])) {
|
||||
$value = filterRequest($field);
|
||||
$fields[] = "`$field` = :$field";
|
||||
$params[":$field"] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($fields)) {
|
||||
jsonError("No fields provided for update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$setClause = implode(", ", $fields);
|
||||
$sql = "UPDATE `waitingRides` SET $setClause WHERE `id` = :id";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
jsonSuccess(null, "Waiting ride data updated successfully");
|
||||
} else {
|
||||
jsonError("Failed to update waiting ride data");
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user