- Timestamp:
- 01/20/10 22:02:30 (13 years ago)
- Branches:
- master, qt5
- Children:
- 8fe9bd2
- Parents:
- 926f106
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sql/sqlengine.cpp
r926f106 r4693fa6 87 87 if (db.isValid() && db.isOpen()) 88 88 { 89 // track /activityhas to be handled as the first, since it is necessary to get90 // track ID from the ACTIVITY table, or to create new ACTIVITYrecord89 // track has to be handled as the first, since it is necessary to get 90 // track ID from the TRACK table, or to create new TRACK record 91 91 // and get the ID from newly created record 92 QString queryExist = QString("SELECT id FROM activityWHERE name='%1'").arg(aEvent["track"]);92 QString queryExist = QString("SELECT id FROM track WHERE name='%1'").arg(aEvent["track"]); 93 93 QSqlQuery resultExist(queryExist,db); 94 // now we have to check whether ACTIVITY record with 'name' exists or not, 95 // - if it doesn't exist yet, then we have to add that record to 'ACTIVITY' table 96 // and assign autoincremented 'id' to aActivity 97 // - if it exists, then we need to get its 'id' and assign it to aRoom 94 // now we have to check whether TRACK record with 'name' exists or not, 95 // - if it doesn't exist yet, then we have to add that record to 'TRACK' table 96 // - if it exists, then we need to get its 'id' 98 97 int actId = -1; 99 if(resultExist.next()) // ACTIVITYrecord with 'name' already exists: we need to get its 'id'98 if(resultExist.next()) // TRACK record with 'name' already exists: we need to get its 'id' 100 99 { 101 100 actId = resultExist.value(0).toInt(); 102 101 } 103 else // ACTIVITYrecord doesn't exist yet, need to create it102 else // TRACK record doesn't exist yet, need to create it 104 103 { 105 104 QString values = QString("'%1'").arg(aEvent["track"]); 106 QString query = QString("INSERT INTO activity(name) VALUES (%1)").arg(values);105 QString query = QString("INSERT INTO track (name) VALUES (%1)").arg(values); 107 106 QSqlQuery result (query, db); 108 107 actId = result.lastInsertId().toInt(); // 'id' is assigned automatically … … 123 122 .arg("0"); 124 123 125 QString query = QString("INSERT INTO EVENT (xid_conference, id, start, duration, xid_ activity, type, language, favourite, alarm) VALUES (%1)").arg(values);124 QString query = QString("INSERT INTO EVENT (xid_conference, id, start, duration, xid_track, type, language, favourite, alarm) VALUES (%1)").arg(values); 126 125 QSqlQuery result (query, db); 127 126 //LOG_AUTOTEST(query); … … 233 232 timeslot_duration INTEGER)"); 234 233 235 query.exec("CREATE TABLE ACTIVITY( \234 query.exec("CREATE TABLE TRACK ( \ 236 235 id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , \ 237 236 name VARCHAR NOT NULL )"); … … 251 250 start INTEGER NOT NULL , \ 252 251 duration INTEGER NOT NULL , \ 253 xid_ activity INTEGER NOT NULL REFERENCES ACTIVITY(id), \252 xid_track INTEGER NOT NULL REFERENCES TRACK(id), \ 254 253 type VARCHAR, \ 255 254 language VARCHAR, \ … … 258 257 PRIMARY KEY (xid_conference,id), \ 259 258 FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id) \ 260 FOREIGN KEY(xid_ activity) REFERENCES ACTIVITY(id))");259 FOREIGN KEY(xid_track) REFERENCES TRACK(id))"); 261 260 262 261 #ifdef MAEMO
Note: See TracChangeset
for help on using the changeset viewer.