diff options
author | Louie S <louie@example.com> | 2024-02-28 18:39:48 -0500 |
---|---|---|
committer | Louie S <louie@example.com> | 2024-02-28 18:39:48 -0500 |
commit | 9c05cd5b5e9250f3cfd04a98370595db8ef8f697 (patch) | |
tree | 83e0841539708b3a3d6fbfd19369b11242e4a6c6 /src/backend/db_sqlite.cpp | |
parent | 34a6045e57a117b9035a12cfe107048e700fe8fd (diff) |
Working add_group_form
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; +} |