Changeset 926f106 for src/sql/sqlengine.cpp
- Timestamp:
- 01/20/10 21:23:13 (13 years ago)
- Branches:
- master, qt5
- Children:
- 4693fa6
- Parents:
- 4e071a3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sql/sqlengine.cpp
r4e071a3 r926f106 87 87 if (db.isValid() && db.isOpen()) 88 88 { 89 // track/activity has to be handled as the first, since it is necessary to get 90 // track ID from the ACTIVITY table, or to create new ACTIVITY record 91 // and get the ID from newly created record 92 QString queryExist = QString("SELECT id FROM activity WHERE name='%1'").arg(aEvent["track"]); 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 98 int actId = -1; 99 if(resultExist.next()) // ACTIVITY record with 'name' already exists: we need to get its 'id' 100 { 101 actId = resultExist.value(0).toInt(); 102 } 103 else // ACTIVITY record doesn't exist yet, need to create it 104 { 105 QString values = QString("'%1'").arg(aEvent["track"]); 106 QString query = QString("INSERT INTO activity (name) VALUES (%1)").arg(values); 107 QSqlQuery result (query, db); 108 actId = result.lastInsertId().toInt(); // 'id' is assigned automatically 109 } 110 89 111 // The items of the Event are divided into the two tables EVENT and VIRTUAL_EVENT 90 112 // VIRTUAL_EVENT is for Full-Text-Serach Support … … 95 117 .arg(QString::number(startDateTime.toTime_t())) \ 96 118 .arg(-QTime::fromString(aEvent["duration"],TIME_FORMAT).secsTo(QTime(0,0))) \ 97 .arg( "123456") \119 .arg(QString::number(actId)) \ 98 120 .arg(aEvent["type"]) \ 99 121 .arg(aEvent["language"]) \
Note: See TracChangeset
for help on using the changeset viewer.