Changeset 51529bd


Ignore:
Timestamp:
06/22/11 19:51:30 (10 years ago)
Author:
gregor herrmann <gregoa@…>
Branches:
master, qt5
Children:
f657e9c
Parents:
cfe9990
Message:

Insert new field xid_conference into table track, room and person.

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/track.cpp

    rcfe9990 r51529bd  
    2121
    2222QString const Track::sTableName = QString("track");
    23 int const Track::sTableColCount = 2;
     23int const Track::sTableColCount = 3;
     24const QString Track::CONFERENCEID = "xid_conference";
    2425const QString Track::NAME = "name";
    2526
    2627QSqlRecord const Track::sColumns = Track::toRecord(QList<QSqlField>()
    2728    << QSqlField("id", QVariant::Int)
     29    << QSqlField(CONFERENCEID, QVariant::Int)
    2830    << QSqlField(NAME, QVariant::String));
    2931
     
    3739{
    3840    QSqlQuery query;
    39     query.prepare("INSERT INTO " + sTableName + " (" + NAME + ")" + " VALUES " + "(\"" + name() + "\")");
     41    query.prepare("INSERT INTO " + sTableName + " (" + CONFERENCEID + "," + NAME + ")" + " VALUES " + "(\"" + QString::number(conferenceid()) + "\",\"" + name() + "\")");
    4042    if (!query.exec())
    4143    {
  • src/mvc/track.h

    rcfe9990 r51529bd  
    2929    static QString const sTableName;
    3030    static const int sTableColCount;
     31    static const QString CONFERENCEID;
    3132    static const QString NAME;
    3233public:
    3334    int id() const { return value("id").toInt(); }
    3435    void setId(int id) { setValue("id", id); }
     36    int conferenceid() const { return value("xid_conference").toInt(); }
     37    void setConference(int conferenceid) { setValue("xid_conference", conferenceid); }
    3538    QString name() const { return value("name").toString(); }
    3639    void setName(const QString & type) { setValue("name", type); }
  • src/sql/sqlengine.cpp

    rcfe9990 r51529bd  
    132132    {
    133133        //insert event track to table and get track id
     134        int conference = aEvent["conference_id"].toInt();
    134135        QString name = aEvent["track"];
    135136        Track track;
     
    142143        }
    143144        catch (OrmNoObjectException &e) {
     145            track.setConference(conference);
    144146            track.setName(name);
    145147            trackId = track.insert();
     
    212214    if (db.isValid() && db.isOpen())
    213215    {
    214         QString values = QString("'%1', '%2'").arg(aPerson["id"],aPerson["name"]);
    215         QString query = QString("INSERT INTO PERSON (id,name) VALUES (%1)").arg(values);
     216        QString values = QString("'%1', '%2', '%3'").arg(aPerson["conference_id"],aPerson["id"],aPerson["name"]);
     217        QString query = QString("INSERT INTO PERSON (xid_conference,id,name) VALUES (%1)").arg(values);
    216218        QSqlQuery result (query, db);
    217219        //LOG_AUTOTEST(query);
     
    243245        else // ROOM record doesn't exist yet, need to create it
    244246        {
    245             QString values = QString("'%1', '%2'").arg(aRoom["name"],aRoom["picture"]);
    246             QString query = QString("INSERT INTO ROOM (name,picture) VALUES (%1)").arg(values);
     247            QString values = QString("'%1', '%2', '%3'").arg(aRoom["conference_id"],aRoom["name"],aRoom["picture"]);
     248            QString query = QString("INSERT INTO ROOM (xid_conference,name,picture) VALUES (%1)").arg(values);
    247249            QSqlQuery result (query, db);
    248250            roomId = result.lastInsertId().toInt(); // 'id' is assigned automatically
Note: See TracChangeset for help on using the changeset viewer.