source: src/mvc/room.cpp @ 2104023

qt5
Last change on this file since 2104023 was a790a90, checked in by pavelpa <pavelpa@…>, 12 years ago

removed headers from *.h and *.cpp

  • Property mode set to 100644
File size: 992 bytes
Line 
1
2#include "room.h"
3
4QString const Room::sTableName = QString("room");
5int const Room::sTableColCount = 3;
6const QString Room::NAME = "name";
7
8QSqlRecord const Room::sColumns = Room::toRecord(QList<QSqlField>()
9    << QSqlField("id", QVariant::Int)
10    << QSqlField(NAME, QVariant::String)
11    << QSqlField("picture", QVariant::String));
12
13Room Room::retrieveByName(QString name)
14{
15    QSqlQuery query;
16    query.prepare(
17            selectQuery()
18            + QString("WHERE %1.name = :name").arg(sTableName));
19    query.bindValue(":name", name);
20    return loadOne(query);
21}
22
23QList<Room> Room::getAll()
24{
25    QSqlQuery query;
26    query.prepare(selectQuery());
27    return load(query);
28}
29
30Room Room::retrieve(int id)
31{
32    QSqlQuery query;
33    query.prepare(selectQuery()
34            + QString("WHERE %1.id = :id").arg(sTableName));
35    query.bindValue(":id", id);
36    return loadOne(query);
37}
38
39QString Room::retrieveRoomName(int id)
40{
41    Room room = retrieve(id);
42    return room.name();
43}
44
Note: See TracBrowser for help on using the repository browser.