From f4e78b03800068498ab72b24f54d9d2c2ab71201 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sat, 2 Jan 2010 19:14:29 +0100 Subject: Implemented removal of tags. --- db.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'db.c') diff --git a/db.c b/db.c index 86a10f8..d47793a 100644 --- a/db.c +++ b/db.c @@ -428,6 +428,54 @@ sqlite_uint64 db_add_tag(const char *name) { } } +static void db_remove_tag_walltags(sqlite_uint64 tagid) { + sqlite3_stmt *stmt; + int rc; + + rc = sqlite3_prepare_v2(db, "DELETE FROM walltags WHERE tagid = ?", -1, &stmt, NULL); + + if(rc != SQLITE_OK) { + return; + } + + rc = sqlite3_bind_int64(stmt, 1, tagid); + if(rc != SQLITE_OK) { + sqlite3_finalize(stmt); + return; + } + + sqlite3_step(stmt); + + sqlite3_finalize(stmt); +} + +static void db_remove_tag_tag(sqlite_uint64 tagid) { + sqlite3_stmt *stmt; + int rc; + + rc = sqlite3_prepare_v2(db, "DELETE FROM tag WHERE id = ?", -1, &stmt, NULL); + + if(rc != SQLITE_OK) { + return; + } + + rc = sqlite3_bind_int64(stmt, 1, tagid); + if(rc != SQLITE_OK) { + sqlite3_finalize(stmt); + return; + } + + sqlite3_step(stmt); + + sqlite3_finalize(stmt); +} + +void db_remove_tag(sqlite_uint64 tagid) { + db_remove_tag_walltags(tagid); + + db_remove_tag_tag(tagid); +} + int db_get_tags_all(GArray **array) { struct tag_t temp, *temp2; sqlite3_stmt *stmt; -- cgit v1.2.3