Software / code / prosody
Comparison
plugins/mod_storage_sql2.lua @ 6060:de4c83feb064
mod_storage_sql2: Build counter query without ORDER BY clause
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 08 Apr 2014 19:23:11 +0200 |
| parent | 6013:918ab89cb68d |
| child | 6165:6a184b16b717 |
comparison
equal
deleted
inserted
replaced
| 6058:1607b03356ed | 6060:de4c83feb064 |
|---|---|
| 287 | 287 |
| 288 archive_where(query, args, where); | 288 archive_where(query, args, where); |
| 289 | 289 |
| 290 -- Total matching | 290 -- Total matching |
| 291 if query.total then | 291 if query.total then |
| 292 local stats = engine:select(sql_query:gsub("^(SELECT).-(FROM)", "%1 COUNT(*) %2"):format(t_concat(where, " AND "), "DESC", ""), unpack(args)); | 292 local stats = engine:select("SELECT COUNT(*) FROM `prosodyarchive` WHERE " .. t_concat(where, " AND "), unpack(args)); |
| 293 if stats then | 293 if stats then |
| 294 local _total = stats() | 294 local _total = stats() |
| 295 total = _total and _total[1]; | 295 total = _total and _total[1]; |
| 296 end | 296 end |
| 297 if query.limit == 0 then -- Skip the real query | 297 if query.limit == 0 then -- Skip the real query |