diff options
Diffstat (limited to 'src/backend/db_sqlite.cpp')
-rw-r--r-- | src/backend/db_sqlite.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/backend/db_sqlite.cpp b/src/backend/db_sqlite.cpp index 9cd73f5..4479b09 100644 --- a/src/backend/db_sqlite.cpp +++ b/src/backend/db_sqlite.cpp @@ -91,7 +91,7 @@ QList<Group *> BackendDB::loadGroups() { } // load entries -QList<Entry *> loadEntries() { +QList<Entry *> BackendDB::loadEntries() { QSqlDatabase database = openDB(); QSqlQuery query; QList<Entry *> output; @@ -116,7 +116,7 @@ QList<Entry *> loadEntries() { } // load entries -QList<Rule *> loadRules() { +QList<Rule *> BackendDB::loadRules() { QSqlDatabase database = openDB(); QSqlQuery query; QList<Rule *> output; @@ -135,3 +135,20 @@ QList<Rule *> loadRules() { database.close(); return output; } + +// insert group to the database (returns 0 if failed) +int BackendDB::insertGroup(const Group &new_group) { + QSqlDatabase database = openDB(); + QSqlQuery query; + int output; + + query.prepare("INSERT INTO groups (name, column, link) VALUES (?, ?, ?)"); + query.bindValue(0, new_group.name); + query.bindValue(1, new_group.column); + query.bindValue(2, new_group.link); + query.exec(); + + output = query.lastInsertId().toInt(); + database.close(); + return output; +} |