diff --git a/database/settings.anubis b/database/settings.anubis index 41c42b8..6448676 100644 --- a/database/settings.anubis +++ b/database/settings.anubis @@ -6,7 +6,6 @@ */ read tools/basis.anubis -read data_base/db_tools.anubis read data_base/sqlite.anubis read calexium_lib/database/db_utils.anubis @@ -15,7 +14,7 @@ read calexium_lib/database/db_utils.anubis public define Maybe(String) select_settings ( - Database db, + SQLite3DataBase db, String var, )= if sql_query_timeout(db, "SELECT var_value FROM settings WHERE var_name=" + db_make_sql_string(var) + ";", "select_settings") is @@ -33,7 +32,7 @@ public define Maybe(String) public define String select_settings ( - Database db, + SQLite3DataBase db, String var, String default )= @@ -46,7 +45,7 @@ public define String public define Int select_settings ( - Database db, + SQLite3DataBase db, String var, Int default )= @@ -64,7 +63,7 @@ public define Int public define Bool select_settings ( - Database db, + SQLite3DataBase db, String var, Bool default )= @@ -78,47 +77,17 @@ public define Bool success(v) then v!=0 } }. - -public define One - update_settings - ( - SQLite3DataBase db, - String var, - Bool value - )= - with binds = (List(SQLite3Bind))[bind_String("@name", var), bind_Int("@value", if value then 1 else 0)], - if select_settings(db, var) is success(_) then - forget(sql_query_timeout(db, "UPDATE settings SET var_value = @value WHERE var_name = @name;", binds, "update_settings")) - else - forget(sql_query_timeout(db, "INSERT INTO settings (var_name, var_value) VALUES (@name, @value)", binds, "update_settings")) - . public define One update_settings ( - Database db, - String var, - Int value - )= - with binds = (List(SQLite3Bind))[bind_String("@name", var), bind_Int("@value", value)], - if select_settings(db, var) is success(_) then - forget(sql_query_timeout(db, "UPDATE settings SET var_value = @value WHERE var_name = @name;", binds, "update_settings")) - else - forget(sql_query_timeout(db, "INSERT INTO settings (var_name, var_value) VALUES (@name, @value)", binds, "update_settings")) - . - - -public define One - update_settings - ( SQLite3DataBase db, String var, String value )= - with binds = (List(SQLite3Bind))[bind_String("@name", var), bind_String("@value", value)], if select_settings(db, var) is success(_) then - forget(sql_query_timeout(db, "UPDATE settings SET var_value = @value WHERE var_name = @name;", binds, "update_settings")) + forget(sql_query_timeout(db, "UPDATE settings SET var_value = @value WHERE var_name = @name;", [bind_String("@name", var), bind_String("@value", value)], "update_settings")) else - forget(sql_query_timeout(db, "INSERT INTO settings (var_name, var_value) VALUES (@name, @value)", binds, "update_settings")) + forget(sql_query_timeout(db, "INSERT INTO settings (var_name, var_value) VALUES (@name, @value)", [bind_String("@name", var), bind_String("@value", value)], "update_settings")) . -- libgit2 0.21.4