| 94 | } |
| 95 | |
| 96 | quint32 DBHelper::getNumChildrenFromFolder(qulonglong libraryId, qulonglong folderId) |
| 97 | { |
| 98 | QString libraryPath = DBHelper::getLibraries().getPath(libraryId); |
| 99 | quint32 result = 0; |
| 100 | QString connectionName = ""; |
| 101 | |
| 102 | { |
| 103 | QSqlDatabase db = DataBaseManagement::loadDatabase(LibraryPaths::libraryDataPath(libraryPath)); |
| 104 | |
| 105 | QSqlQuery selectQuery(db); |
| 106 | selectQuery.prepare("SELECT count(*) FROM folder WHERE parentId = :parentId and id <> 1"); |
| 107 | selectQuery.bindValue(":parentId", folderId); |
| 108 | selectQuery.exec(); |
| 109 | |
| 110 | result += selectQuery.record().value(0).toULongLong(); |
| 111 | |
| 112 | selectQuery.prepare("SELECT count(*) FROM comic c WHERE c.parentId = :parentId"); |
| 113 | selectQuery.bindValue(":parentId", folderId); |
| 114 | selectQuery.exec(); |
| 115 | |
| 116 | result += selectQuery.record().value(0).toULongLong(); |
| 117 | connectionName = db.connectionName(); |
| 118 | } |
| 119 | |
| 120 | QSqlDatabase::removeDatabase(connectionName); |
| 121 | |
| 122 | return result; |
| 123 | } |
| 124 | |
| 125 | qulonglong DBHelper::getParentFromComicFolderId(qulonglong libraryId, qulonglong id) |
| 126 | { |