-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflight.cpp
More file actions
19 lines (18 loc) · 756 Bytes
/
flight.cpp
File metadata and controls
19 lines (18 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "flight.h"
#include "databaseManagement.h"
Flight Flight::findById(int id) {
QSqlDatabase db = DatabaseManager::instance().getDatabase("FlightDB");
QSqlQuery query(db);
query.prepare("SELECT * FROM flights WHERE id = :id");
query.bindValue(":id", id);
Flight flight;
if (query.exec() && query.next()) {
flight.id = query.value("id").toInt();
flight.flightNumber = query.value("flight_number").toString();
flight.departure = query.value("departure").toString();
flight.destination = query.value("destination").toString();
flight.departureTime = query.value("departure_time").toString();
flight.arrivalTime = query.value("arrival_time").toString();
}
return flight;
}