Commit 5ea5b038c8df722da22e8032931dd59a962959a1
1 parent
18c9bbfa
Upgrading sources to Anubis version 1.11.0.4
Showing
1 changed file
with
33 additions
and
2 deletions
Show diff stats
database/settings.anubis
| @@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | read tools/basis.anubis | 8 | read tools/basis.anubis |
| 9 | +read data_base/db_tools.anubis | ||
| 9 | read data_base/sqlite.anubis | 10 | read data_base/sqlite.anubis |
| 10 | 11 | ||
| 11 | read calexium_lib/database/db_utils.anubis | 12 | read calexium_lib/database/db_utils.anubis |
| @@ -77,17 +78,47 @@ public define Bool | @@ -77,17 +78,47 @@ public define Bool | ||
| 77 | success(v) then v!=0 | 78 | success(v) then v!=0 |
| 78 | } | 79 | } |
| 79 | }. | 80 | }. |
| 81 | + | ||
| 82 | +public define One | ||
| 83 | + update_settings | ||
| 84 | + ( | ||
| 85 | + SQLite3DataBase db, | ||
| 86 | + String var, | ||
| 87 | + Bool value | ||
| 88 | + )= | ||
| 89 | + with binds = (List(SQLite3Bind))[bind_String("@name", var), bind_Int("@value", if value then 1 else 0)], | ||
| 90 | + if select_settings(db, var) is success(_) then | ||
| 91 | + forget(sql_query_timeout(db, "UPDATE settings SET var_value = @value WHERE var_name = @name;", binds, "update_settings")) | ||
| 92 | + else | ||
| 93 | + forget(sql_query_timeout(db, "INSERT INTO settings (var_name, var_value) VALUES (@name, @value)", binds, "update_settings")) | ||
| 94 | + . | ||
| 80 | 95 | ||
| 81 | public define One | 96 | public define One |
| 82 | update_settings | 97 | update_settings |
| 83 | ( | 98 | ( |
| 84 | SQLite3DataBase db, | 99 | SQLite3DataBase db, |
| 85 | String var, | 100 | String var, |
| 101 | + Int value | ||
| 102 | + )= | ||
| 103 | + with binds = (List(SQLite3Bind))[bind_String("@name", var), bind_Int("@value", value)], | ||
| 104 | + if select_settings(db, var) is success(_) then | ||
| 105 | + forget(sql_query_timeout(db, "UPDATE settings SET var_value = @value WHERE var_name = @name;", binds, "update_settings")) | ||
| 106 | + else | ||
| 107 | + forget(sql_query_timeout(db, "INSERT INTO settings (var_name, var_value) VALUES (@name, @value)", binds, "update_settings")) | ||
| 108 | + . | ||
| 109 | + | ||
| 110 | + | ||
| 111 | +public define One | ||
| 112 | + update_settings | ||
| 113 | + ( | ||
| 114 | + SQLite3DataBase db, | ||
| 115 | + String var, | ||
| 86 | String value | 116 | String value |
| 87 | )= | 117 | )= |
| 118 | + with binds = (List(SQLite3Bind))[bind_String("@name", var), bind_String("@value", value)], | ||
| 88 | if select_settings(db, var) is success(_) then | 119 | if select_settings(db, var) is success(_) then |
| 89 | - 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")) | 120 | + forget(sql_query_timeout(db, "UPDATE settings SET var_value = @value WHERE var_name = @name;", binds, "update_settings")) |
| 90 | else | 121 | else |
| 91 | - 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")) | 122 | + forget(sql_query_timeout(db, "INSERT INTO settings (var_name, var_value) VALUES (@name, @value)", binds, "update_settings")) |
| 92 | . | 123 | . |
| 93 | 124 |