aboutsummaryrefslogtreecommitdiffstats
path: root/src/dbhelper.c
diff options
context:
space:
mode:
authorAnastasis Grammenos <anastasis.gramm2@gmail.com>2018-10-03 13:25:21 +0300
committerAnastasis Grammenos <anastasis.gramm2@gmail.com>2018-10-03 13:25:21 +0300
commit1cfbedd0b199d77ed53e5224435a76978875e2fb (patch)
tree8bfbb856ab4e02a8c5d0085ff6b75e09cbac8f18 /src/dbhelper.c
parent6d162956409c0fa394920ba707109afdbff041e5 (diff)
downloadck-1cfbedd0b199d77ed53e5224435a76978875e2fb.tar.gz
ck-1cfbedd0b199d77ed53e5224435a76978875e2fb.tar.bz2
ck-1cfbedd0b199d77ed53e5224435a76978875e2fb.zip
Work on delete
Diffstat (limited to 'src/dbhelper.c')
-rw-r--r--src/dbhelper.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/dbhelper.c b/src/dbhelper.c
index b183770..8e4d9ad 100644
--- a/src/dbhelper.c
+++ b/src/dbhelper.c
@@ -193,3 +193,35 @@ void dbh_form_query_select_programs(char *query) {
strcpy(query, tmp);
}
+
+void dbh_form_query_delete_x_from_y(char *query, const char *x, const char *y) {
+ char tmp[STR_M] = "DELETE FROM ";
+ strcat(tmp, y);
+ strcat(tmp, " WHERE ");
+ strcat(tmp, x);
+ strcat(tmp, " = ?;");
+
+ strcpy(query, tmp);
+}
+
+void dbh_from_query_count_program_relations(char *query) {
+ char tmp[STR_M] = "SELECT COUNT(*) FROM ";
+ strcat(tmp, TBL_REL);
+ strcat(tmp, " WHERE ");
+ strcat(tmp, COL_REL_PROGRAM_ID);
+ strcat(tmp, " = ?;");
+
+ strcpy(query, tmp);
+}
+
+void dbh_form_query_get_pid_from_cid(char *query) {
+ char tmp[STR_M] = "SELECT ";
+ strcat(tmp, COL_REL_PROGRAM_ID);
+ strcat(tmp, " FROM ");
+ strcat(tmp, TBL_REL);
+ strcat(tmp, " WHERE ");
+ strcat(tmp, COL_REL_CONFIG_ID);
+ strcat(tmp, " = ?;");
+
+ strcpy(query, tmp);
+}