summaryrefslogtreecommitdiff
path: root/db.c
diff options
context:
space:
mode:
Diffstat (limited to 'db.c')
-rw-r--r--db.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/db.c b/db.c
index 6b0bd22..e6f0368 100644
--- a/db.c
+++ b/db.c
@@ -515,11 +515,11 @@ int db_get_walls_by_tags(GArray *tags, GArray **array) {
return 1;
}
-sqlite_uint64 db_add_tag(const char *name) {
+sqlite_uint64 db_add_tag(const char *name, sqlite_uint64 parent) {
sqlite3_stmt *stmt;
int rc;
- rc = sqlite3_prepare_v2(db, "INSERT INTO tag (name) VALUES (?)", -1, &stmt, NULL);
+ rc = sqlite3_prepare_v2(db, "INSERT INTO tag (name, parent) VALUES (?, ?)", -1, &stmt, NULL);
if(rc != SQLITE_OK) {
return 0;
@@ -531,6 +531,16 @@ sqlite_uint64 db_add_tag(const char *name) {
return 0;
}
+ if(parent == 0) {
+ rc = sqlite3_bind_null(stmt, 2);
+ } else {
+ rc = sqlite3_bind_int64(stmt, 2, parent);
+ }
+ if(rc != SQLITE_OK) {
+ sqlite3_finalize(stmt);
+ return 0;
+ }
+
rc = sqlite3_step(stmt);
sqlite3_finalize(stmt);