Пример #1
0
function update_ride_request_status($driver_id, $data)
{
    $trip = database\get_trip($data['trip_id']);
    if ($trip['driver_id'] != $driver_id) {
        return functions\json_respond('ERROR', 'Unauthorized access!');
    }
    $spots_remaining = database\update_ride_request_status($data['user_id'], $data['trip_id'], $data['status']);
    if ($spots_remaining < 0) {
        return functions\json_respond('ERROR', 'Insufficient spots!');
    }
    functions\json_respond('OK', 'Query performed!', array("spots_remaining" => $spots_remaining));
}
Пример #2
0
function delete_trip($trip_id)
{
    $trip_table = 'trip';
    $place_table = 'place';
    $trip = database\get_trip($trip_id);
    if ($trip) {
        $origin = $trip['origin']['id'];
        $destination = $trip['destination']['id'];
        var_dump($origin, $destination);
        $delete_trip = mysql_query("DELETE FROM {$trip_table} WHERE id={$trip_id}");
        $delete_place_1 = mysql_query("DELETE FROM {$place_table} WHERE id= {$origin} ");
        $delete_place_2 = mysql_query("DELETE FROM {$place_table} WHERE id={$destination}");
        if ($delete_trip & $delete_place_1 & $delete_place_2) {
            var_dump("Deleted Trip!");
            return true;
            // Trip successfully deleted
        }
        return false;
        // Failed to delete the trip
    }
    var_dump("Not Deleted!");
    return false;
    // The trip is not in the trip table
}