diff --git a/controller/hk_sql_utils.anubis b/controller/hk_sql_utils.anubis index 3ce21f5..7ccf95a 100644 --- a/controller/hk_sql_utils.anubis +++ b/controller/hk_sql_utils.anubis @@ -47,7 +47,20 @@ public define Maybe(One) error(_) then failure, ok(_, _, _) then success(unique) }. - + +public define Int + get_count_by_full_clause + ( + SQLite3DataBase db, + String clause + )= + if sql_query_timeout(db, clause+";", [], "get_count_by_clause") is + { + error(_) then 0, + ok(_, cursor, _) then db_get_integer(cursor) + } +. + public define Int get_count_by_clause ( @@ -55,18 +68,19 @@ public define Int String table_name, String clause )= - with final_clause = if clause = "" then - "" - else - "WHERE "+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 + if sql_query_timeout(db, "SELECT COUNT(\""+table_name+".id\") FROM "+table_name+" "+clause+";", [], "get_count_by_clause") is { error(_) then 0, ok(_, cursor, _) then db_get_integer(cursor) } . + public define Int get_count ( -- libgit2 0.21.4