source: src/mvc/room.cpp @ c7b58d4

qt5
Last change on this file since c7b58d4 was 7620de0, checked in by korrco <korrco@…>, 13 years ago

room view added - need to test it

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