Adding database loading and data conversion to orm module
[toast/confclerk.git] / src / model / event.cpp
1 #include "event.h"
2
3 QSqlRecord const Event::sColumns = Event::toRecord(QList<QSqlField>()
4     << QSqlField("id", QVariant::Int)
5     << QSqlField("xid_conference", QVariant::Int)
6     << QSqlField("start", QVariant::DateTime)
7     << QSqlField("duration", QVariant::Int)
8     << QSqlField("xid_activity", QVariant::Int)
9     << QSqlField("type", QVariant::String)
10     << QSqlField("language", QVariant::String));
11
12 QString const Event::sTableName = QString("event");
13
14 Event Event::getById(int id, int conferenceId)
15 {
16     QString query = selectQuery() + "WHERE id = :id AND xid_conference = :conf";
17
18     QSqlQuery q;
19     q.prepare(query);
20     q.bindValue(":id", id);
21     q.bindValue(":conf", conferenceId);
22     return loadOne(q);
23 }