Changeset c790268 for src/mvc/event.cpp


Ignore:
Timestamp:
01/17/10 17:22:03 (12 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
6f39595
Parents:
680a4da
Message:

implemented JOINing two tables

  • modified 'ormrecord' to support JOINing two tables
  • modified 'event' accordingly, since its items/columns are splitted into two separate tables
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/event.cpp

    r680a4da rc790268  
    11#include "event.h"
    22
     3// 'event' record is splitted into two separate tables 'event' and 'virtual_event'
     4// for the FTS (Full-Text-Search) support and so, it is necessary to provide/use
     5// two table names + corresponding parameters/methods, see bellow
     6QString const Event::sTable1Name = QString("event");
     7QString const Event::sTable2Name = QString("virtual_event");
     8int const Event::sTable1ColCount = 8; // see 'toRecord()' for more details
     9int const Event::sTable2ColCount = 5; // see 'toRecord()' for more details
     10
    311QSqlRecord const Event::sColumns = Event::toRecord(QList<QSqlField>()
     12    /* 'columns from Table 1 */
    413    << QSqlField("id", QVariant::Int)
    514    << QSqlField("xid_conference", QVariant::Int)
     
    918    << QSqlField("type", QVariant::String)
    1019    << QSqlField("language", QVariant::String)
    11     << QSqlField("favourite", QVariant::Bool));
     20    << QSqlField("favourite", QVariant::Bool)
     21    /* 'columns' from Table2 */
     22    << QSqlField("tag", QVariant::String)
     23    << QSqlField("title", QVariant::String)
     24    << QSqlField("subtitle", QVariant::String)
     25    << QSqlField("abstract", QVariant::String)
     26    << QSqlField("description", QVariant::String));
    1227
    13 QString const Event::sTableName = QString("event");
    1428
    1529Event Event::getById(int id, int conferenceId)
    1630{
    1731    QSqlQuery query;
    18     query.prepare(selectQuery() + "WHERE id = :id AND xid_conference = :conf");
     32    query.prepare(selectQueryJoin2T("id") + "WHERE event.id = :id AND event.xid_conference = :conf");
    1933    query.bindValue(":id", id);
    2034    query.bindValue(":conf", conferenceId);
     35
    2136    return loadOne(query);
    2237}
     
    2540{
    2641    QSqlQuery query;
    27     query.prepare(selectQuery() + "WHERE xid_conference = :conf AND start >= :start AND start < :end ORDER BY start");
     42    query.prepare(selectQueryJoin2T("id") + "WHERE event.xid_conference = :conf AND event.start >= :start AND event.start < :end ORDER BY event.start");
    2843    query.bindValue(":conf", conferenceId);
    2944    query.bindValue(":start", convertToDb(date, QVariant::DateTime));
Note: See TracChangeset for help on using the changeset viewer.