| 1559 | } |
| 1560 | |
| 1561 | void DBHelper::insertComicsInLabel(const QList<ComicDB> &comicsList, qulonglong labelId, QSqlDatabase &db) |
| 1562 | { |
| 1563 | QSqlQuery getNumComics(QString("SELECT count(*) FROM comic_label WHERE label_id = %1;").arg(labelId), db); |
| 1564 | getNumComics.next(); |
| 1565 | |
| 1566 | int numComics = getNumComics.value(0).toInt(); |
| 1567 | |
| 1568 | db.transaction(); |
| 1569 | |
| 1570 | QSqlQuery query(db); |
| 1571 | query.prepare("INSERT INTO comic_label (label_id, comic_id, ordering) " |
| 1572 | "VALUES (:label_id, :comic_id, :ordering)"); |
| 1573 | |
| 1574 | for (const auto &comic : comicsList) { |
| 1575 | query.bindValue(":label_id", labelId); |
| 1576 | query.bindValue(":comic_id", comic.id); |
| 1577 | query.bindValue(":ordering", numComics++); |
| 1578 | query.exec(); |
| 1579 | } |
| 1580 | |
| 1581 | QLOG_TRACE() << query.lastError(); |
| 1582 | |
| 1583 | db.commit(); |
| 1584 | } |
| 1585 | |
| 1586 | void DBHelper::insertComicsInReadingList(const QList<ComicDB> &comicsList, qulonglong readingListId, QSqlDatabase &db) |
| 1587 | { |