Paper DatabaseHelper::getPaper(int paperId) { QSqlQuery query; query.prepare("SELECT year, book_title_id, title, path, comment FROM pl_paper WHERE paper_id = :paper_id"); query.bindValue(":paper_id", paperId); query.exec(); Paper paper; if (!query.last()) return paper; paper.setId(paperId); paper.setYear(query.value(0).toInt()); paper.setBookTitle(getBookTitle(query.value(1).toInt())); paper.setTitle(query.value(2).toString().toStdString()); paper.setPath(query.value(3).toString().toStdString()); paper.setComment(query.value(4).toString().toStdString()); query.prepare("SELECT author_id FROM pl_paper2author WHERE paper_id = :paper_id ORDER BY rowid ASC"); query.bindValue(":paper_id", paperId); query.exec(); vector<string> authors; while (query.next()) { int authorId = query.value(0).toInt(); authors.push_back(getAuthor(authorId)); } query.prepare("SELECT tag_id FROM pl_paper2tag WHERE paper_id = :paper_id"); query.bindValue(":paper_id", paperId); query.exec(); vector<string> tags; while (query.next()) { int tagId = query.value(0).toInt(); tags.push_back(getTag(tagId)); } paper.setAuthors(authors); paper.setTags(tags); return paper; }