Commit c91bcb7aa0155e31a4396cb5b2c69b2f57bdece4
1 parent
2c3918d5
[+] get_db_ids_by_clause helper to get list of DB_id from table and column. For …
…example this help to get list of foreign keys
Showing
1 changed file
with
20 additions
and
0 deletions
Show diff stats
controller/hk_sql_utils.anubis
| ... | ... | @@ -179,6 +179,26 @@ public define List(Int) |
| 179 | 179 | } |
| 180 | 180 | . |
| 181 | 181 | |
| 182 | +public define List(DB_id) | |
| 183 | + get_db_ids_by_clause | |
| 184 | + ( | |
| 185 | + SQLite3DataBase db, | |
| 186 | + String table_name, | |
| 187 | + String id_col, | |
| 188 | + String clause | |
| 189 | + )= | |
| 190 | + with final_clause = if clause = "" then | |
| 191 | + "" | |
| 192 | + else | |
| 193 | + "WHERE "+clause, | |
| 194 | + | |
| 195 | + if sql_query_timeout(db, "SELECT \""+id_col+"\" FROM "+table_name+" "+final_clause+";", [], "get_ids_by_clause") is | |
| 196 | + { | |
| 197 | + error(_) then [], | |
| 198 | + ok(_, cursor, _) then db_get_List_DB_id(cursor) | |
| 199 | + } | |
| 200 | +. | |
| 201 | + | |
| 182 | 202 | public define Maybe(Int) |
| 183 | 203 | get_mb_id_by_clause |
| 184 | 204 | ( | ... | ... |