Commit 19dca6714a51f22cc5c228eb88e3b1400eed65ee

Authored by David RENE
1 parent 1adb1b60

fix database access

calexium_lib/database/db_utils.anubis
@@ -89,6 +89,28 @@ public define DbQueryResult @@ -89,6 +89,28 @@ public define DbQueryResult
89 ok(headers, cursor, reset) 89 ok(headers, cursor, reset)
90 }. 90 }.
91 91
  92 + public define DbQueryResult
  93 + sql_query_timeout
  94 + (
  95 + Database db, //database handle
  96 + String sql_query, //sql query itself
  97 + String msg //message to be shown if an error occure
  98 + ) =
  99 + sql_query_timeout(db, sql_query, [], msg).
  100 +
  101 +public define Maybe(One -> DbRow)
  102 + sql_query_timeout
  103 + (
  104 + Database db, //database handle
  105 + String sql_query, //sql query itself
  106 + String msg //message to be shown if an error occure
  107 + ) =
  108 + if sql_query_timeout(db, sql_query, [], msg) is
  109 + {
  110 + error(_) then failure,
  111 + ok(_,cursor,_) then success(cursor)
  112 + }.
  113 +
92 // deprecated. Use one of the previous ones. 114 // deprecated. Use one of the previous ones.
93 public define SQLite3QueryResult 115 public define SQLite3QueryResult
94 sql_query_timeout 116 sql_query_timeout
@@ -110,6 +132,15 @@ public define SQLite3QueryResult @@ -110,6 +132,15 @@ public define SQLite3QueryResult
110 ok(headers, cursor, reset) 132 ok(headers, cursor, reset)
111 }. 133 }.
112 134
  135 +public define SQLite3QueryResult
  136 + sql_query_timeout
  137 + (
  138 + SQLite3DataBase db, //database handle
  139 + String sql_query, //sql query itself
  140 + String msg //message to be shown if an error occure
  141 + ) =
  142 + sql_query_timeout(db, sql_query, [], msg).
  143 +
113 // -- Extractors HELPERS --------------- 144 // -- Extractors HELPERS ---------------
114 145
115 public define List(String) 146 public define List(String)
calexium_lib/database/settings.anubis
@@ -15,13 +15,13 @@ public define Maybe(String) @@ -15,13 +15,13 @@ public define Maybe(String)
15 select_settings 15 select_settings
16 ( 16 (
17 Database db, 17 Database db,
18 - String var, 18 + String var,
19 )= 19 )=
20 if sql_query_timeout(db, "SELECT var_value FROM settings WHERE var_name=" + db_make_sql_string(var) + ";", "select_settings") is 20 if sql_query_timeout(db, "SELECT var_value FROM settings WHERE var_name=" + db_make_sql_string(var) + ";", "select_settings") is
21 { 21 {
22 failure then failure, //error in the SQL request 22 failure then failure, //error in the SQL request
23 success(table_cursor) then 23 success(table_cursor) then
24 - if table_cursor(next_row) is 24 + if table_cursor(unique) is
25 { 25 {
26 error(_) then failure, 26 error(_) then failure,
27 no_more_row then failure, //can't find the var_value in the table, because the row is empty 27 no_more_row then failure, //can't find the var_value in the table, because the row is empty