Changeset f0f9fdc in confclerk_git
- Timestamp:
- 09/13/17 23:28:44 (5 years ago)
- Branches:
- master
- Children:
- 7ba0378
- Parents:
- a4d3f7b
- git-author:
- Philipp Spitzer <philipp@…> (09/13/17 23:17:32)
- git-committer:
- Philipp Spitzer <philipp@…> (09/13/17 23:28:44)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sql/sqlengine.cpp
ra4d3f7b rf0f9fdc 142 142 void SqlEngine::addConferenceToDB(QHash<QString,QString> &aConference, int conferenceId) { 143 143 QSqlQuery query(db); 144 if (conferenceId <= 0) // insert conference145 {144 bool insert = conferenceId <= 0; 145 if (insert) { // insert conference 146 146 query.prepare("INSERT INTO CONFERENCE (title,url,subtitle,venue,city,start,end," 147 147 "day_change,timeslot_duration,active) " 148 148 " VALUES (:title,:url,:subtitle,:venue,:city,:start,:end," 149 149 ":day_change,:timeslot_duration,:active)"); 150 foreach (QString prop_name, (QList<QString>() << "title" << "url" << "subtitle" << "venue" << "city")) { 151 query.bindValue(QString(":") + prop_name, aConference[prop_name]); 152 } 153 query.bindValue(":start", QDateTime(QDate::fromString(aConference["start"],DATE_FORMAT),QTime(0,0),Qt::UTC).toTime_t()); 154 query.bindValue(":end", QDateTime(QDate::fromString(aConference["end"],DATE_FORMAT),QTime(0,0),Qt::UTC).toTime_t()); 155 query.bindValue(":day_change", -QTime::fromString(aConference["day_change"],TIME_FORMAT).secsTo(QTime(0,0))); 156 query.bindValue(":timeslot_duration", -QTime::fromString(aConference["timeslot_duration"],TIME_FORMAT).secsTo(QTime(0,0))); 157 query.bindValue(":active", 1); 158 query.exec(); 159 emitSqlQueryError(query); 160 aConference["id"] = query.lastInsertId().toString(); // 'id' is assigned automatically 161 } 162 else // update conference 163 { 150 } else { // update conference 164 151 query.prepare("UPDATE CONFERENCE set title=:title, url=:url, subtitle=:subtitle, venue=:venue, city=:city, start=:start, end=:end," 165 152 "day_change=:day_change, timeslot_duration=:timeslot_duration, active=:active " 166 153 "WHERE id=:id"); 167 foreach (QString prop_name, (QList<QString>() << "title" << "url" << "subtitle" << "venue" << "city")) { 168 query.bindValue(QString(":") + prop_name, aConference[prop_name]); 169 } 170 query.bindValue(":start", QDateTime(QDate::fromString(aConference["start"],DATE_FORMAT),QTime(0,0),Qt::UTC).toTime_t()); 171 query.bindValue(":end", QDateTime(QDate::fromString(aConference["end"],DATE_FORMAT),QTime(0,0),Qt::UTC).toTime_t()); 172 query.bindValue(":day_change", -QTime::fromString(aConference["day_change"],TIME_FORMAT).secsTo(QTime(0,0))); 173 query.bindValue(":timeslot_duration", -QTime::fromString(aConference["timeslot_duration"],TIME_FORMAT).secsTo(QTime(0,0))); 174 query.bindValue(":active", 1); 175 query.bindValue(":id", conferenceId); 176 query.exec(); 177 emitSqlQueryError(query); 154 } 155 foreach (QString prop_name, (QList<QString>() << "title" << "url" << "subtitle" << "venue" << "city")) { 156 query.bindValue(QString(":") + prop_name, aConference[prop_name]); 157 } 158 query.bindValue(":start", QDateTime(QDate::fromString(aConference["start"],DATE_FORMAT),QTime(0,0),Qt::UTC).toTime_t()); 159 query.bindValue(":end", QDateTime(QDate::fromString(aConference["end"],DATE_FORMAT),QTime(0,0),Qt::UTC).toTime_t()); 160 query.bindValue(":day_change", -QTime::fromString(aConference["day_change"],TIME_FORMAT).secsTo(QTime(0,0))); 161 query.bindValue(":timeslot_duration", -QTime::fromString(aConference["timeslot_duration"],TIME_FORMAT).secsTo(QTime(0,0))); 162 query.bindValue(":active", 1); 163 if (!insert) query.bindValue(":id", conferenceId); 164 query.exec(); 165 emitSqlQueryError(query); 166 if (insert) { 167 aConference["id"] = query.lastInsertId().toString(); // 'id' is assigned automatically 168 } else { 178 169 aConference["id"] = QVariant(conferenceId).toString(); 179 170 }
Note: See TracChangeset
for help on using the changeset viewer.