diff --git a/controller/hk_sql_utils.anubis b/controller/hk_sql_utils.anubis index 9320946..6de0419 100644 --- a/controller/hk_sql_utils.anubis +++ b/controller/hk_sql_utils.anubis @@ -6,6 +6,7 @@ * © Calexium */ +read calexium_lib/database/db_utils.anubis read hayamiki_lib/types/hayamiki.anubis public define String @@ -27,3 +28,31 @@ public define String " (1 = 1) ", } . + +public define Int + get_count_by_clause + ( + SQLite3DataBase db, + String table_name, + String clause + )= + with final_clause = if clause = "" then + "" + else + "WHERE "+clause, + + if sql_query_timeout(db, "SELECT COUNT(\"id\") FROM "+table_name+" "+final_clause+";", [], "get_count_by_clause") is + { + error(_) then 0, + ok(_, cursor, _) then db_get_integer(cursor) + } +. + +public define Int + get_count + ( + SQLite3DataBase db, + String table_name + )= + get_count_by_clause(db, table_name, "") +. -- libgit2 0.21.4