Commit 229008fef4182f5f18ce2d14f5cf16c061dcfcfd
1 parent
0b1e3ee3
[+] add get_count_by_clause with list of binds
Showing
1 changed file
with
12 additions
and
2 deletions
Show diff stats
controller/hk_sql_utils.anubis
| ... | ... | @@ -169,20 +169,30 @@ public define Int |
| 169 | 169 | ( |
| 170 | 170 | SQLite3DataBase db, |
| 171 | 171 | String table_name, |
| 172 | - String clause | |
| 172 | + String clause, | |
| 173 | + List(SQLite3Bind) binds | |
| 173 | 174 | )= |
| 174 | 175 | // with final_clause = if clause = "" then |
| 175 | 176 | // "" |
| 176 | 177 | // else |
| 177 | 178 | // "WHERE "+clause, |
| 178 | 179 | |
| 179 | - if sql_query_timeout(db, "SELECT COUNT(\""+table_name+".id\") FROM "+table_name+" "+clause+";", [], "get_count_by_clause") is | |
| 180 | + if sql_query_timeout(db, "SELECT COUNT(\""+table_name+".id\") FROM "+table_name+" "+clause+";", binds, "get_count_by_clause") is | |
| 180 | 181 | { |
| 181 | 182 | error(sql_error) then println("get_count_by_clause SQL ERROR '"+ sql_error.text + "'\n table_name ["+table_name+"]\n clause ["+clause+";]");0, |
| 182 | 183 | ok(_, cursor, _) then db_get_Int(cursor) |
| 183 | 184 | } |
| 184 | 185 | . |
| 185 | 186 | |
| 187 | +public define Int | |
| 188 | + get_count_by_clause | |
| 189 | + ( | |
| 190 | + SQLite3DataBase db, | |
| 191 | + String table_name, | |
| 192 | + String clause | |
| 193 | + )= | |
| 194 | + get_count_by_clause(db, table_name, clause, []) | |
| 195 | +. | |
| 186 | 196 | |
| 187 | 197 | public define Int |
| 188 | 198 | get_count | ... | ... |