Commit accc7490a42d73a0666e87883bf9170dfd85be8b
1 parent
d169d607
[+] db_get_float(db, clause), db_get_float(db, clause, binds).
[+] db_get_Int(db, clause, binds). [+] db_get_ids_by_full_clause(db, table_name, id_col, full_clause, binds).
Showing
1 changed file
with
60 additions
and
2 deletions
Show diff stats
controller/hk_sql_utils.anubis
| @@ -78,6 +78,29 @@ public define Int | @@ -78,6 +78,29 @@ public define Int | ||
| 78 | } | 78 | } |
| 79 | . | 79 | . |
| 80 | 80 | ||
| 81 | +public define Int | ||
| 82 | + db_get_Int | ||
| 83 | + ( | ||
| 84 | + SQLite3DataBase db, | ||
| 85 | + String clause, | ||
| 86 | + List(SQLite3Bind) binds | ||
| 87 | + )= | ||
| 88 | + if sql_query_timeout(db, clause+";", binds, "db_get_Int") is | ||
| 89 | + { | ||
| 90 | + error(sql_error) then println("db_get_Int SQL ERROR '"+ sql_error.text + "'\n clause ["+clause+";]");0, | ||
| 91 | + ok(_, cursor, _) then db_get_Int(cursor) | ||
| 92 | + } | ||
| 93 | +. | ||
| 94 | + | ||
| 95 | +public define Int | ||
| 96 | + db_get_Int | ||
| 97 | + ( | ||
| 98 | + SQLite3DataBase db, | ||
| 99 | + String clause | ||
| 100 | + )= | ||
| 101 | + db_get_Int(db, clause, []) | ||
| 102 | +. | ||
| 103 | + | ||
| 81 | public define Float | 104 | public define Float |
| 82 | get_count_float_by_full_clause | 105 | get_count_float_by_full_clause |
| 83 | ( | 106 | ( |
| @@ -91,6 +114,29 @@ public define Float | @@ -91,6 +114,29 @@ public define Float | ||
| 91 | } | 114 | } |
| 92 | . | 115 | . |
| 93 | 116 | ||
| 117 | +public define Float | ||
| 118 | + db_get_Float | ||
| 119 | + ( | ||
| 120 | + SQLite3DataBase db, | ||
| 121 | + String clause, | ||
| 122 | + List(SQLite3Bind) binds | ||
| 123 | + )= | ||
| 124 | + if sql_query_timeout(db, clause+";", binds, "db_get_Float") is | ||
| 125 | + { | ||
| 126 | + error(sql_error) then println("db_get_Float SQL ERROR '"+ sql_error.text + "'\n clause ["+clause+";]");0.0, | ||
| 127 | + ok(_, cursor, _) then db_get_Float(cursor) | ||
| 128 | + } | ||
| 129 | +. | ||
| 130 | + | ||
| 131 | +public define Float | ||
| 132 | + db_get_Float | ||
| 133 | + ( | ||
| 134 | + SQLite3DataBase db, | ||
| 135 | + String clause | ||
| 136 | + )= | ||
| 137 | + db_get_Float(db, clause, []) | ||
| 138 | +. | ||
| 139 | + | ||
| 94 | public define Int | 140 | public define Int |
| 95 | get_count_by_clause | 141 | get_count_by_clause |
| 96 | ( | 142 | ( |
| @@ -205,16 +251,28 @@ public define List(DB_id) | @@ -205,16 +251,28 @@ public define List(DB_id) | ||
| 205 | SQLite3DataBase db, | 251 | SQLite3DataBase db, |
| 206 | String table_name, | 252 | String table_name, |
| 207 | String id_col, | 253 | String id_col, |
| 208 | - String full_clause | 254 | + String full_clause, |
| 255 | + List(SQLite3Bind) binds | ||
| 209 | )= | 256 | )= |
| 210 | 257 | ||
| 211 | - if sql_query_timeout(db, "SELECT \""+id_col+"\" FROM "+table_name+" "+full_clause+";", [], "get_db_ids_by_full_clause") is | 258 | + if sql_query_timeout(db, "SELECT \""+id_col+"\" FROM "+table_name+" "+full_clause+";", binds, "get_db_ids_by_full_clause") is |
| 212 | { | 259 | { |
| 213 | error(sql_error) then println("get_db_ids_by_full_clause SQL ERROR '"+ sql_error.text + "'\n table_name ["+table_name+"]\n id_col["+id_col+"]\nfull_clause ["+full_clause+";]");[], | 260 | error(sql_error) then println("get_db_ids_by_full_clause SQL ERROR '"+ sql_error.text + "'\n table_name ["+table_name+"]\n id_col["+id_col+"]\nfull_clause ["+full_clause+";]");[], |
| 214 | ok(_, cursor, _) then db_get_List_DB_id(cursor) | 261 | ok(_, cursor, _) then db_get_List_DB_id(cursor) |
| 215 | } | 262 | } |
| 216 | . | 263 | . |
| 217 | 264 | ||
| 265 | +public define List(DB_id) | ||
| 266 | + get_db_ids_by_full_clause | ||
| 267 | + ( | ||
| 268 | + SQLite3DataBase db, | ||
| 269 | + String table_name, | ||
| 270 | + String id_col, | ||
| 271 | + String full_clause | ||
| 272 | + )= | ||
| 273 | + get_db_ids_by_full_clause(db, table_name, id_col, full_clause, []) | ||
| 274 | +. | ||
| 275 | + | ||
| 218 | public define Maybe(Int) | 276 | public define Maybe(Int) |
| 219 | get_mb_id_by_clause | 277 | get_mb_id_by_clause |
| 220 | ( | 278 | ( |