]>
Commit | Line | Data |
---|---|---|
a098bb43 CP |
1 | function db_queryiter() |
2 | local c = db_numrows() | |
3 | local i = -1 | |
4 | local f = db_numfields() | |
5 | local gb = db_getvalue | |
6 | ||
7 | return function() | |
8 | i = i + 1 | |
9 | if i == c then | |
10 | return nil | |
11 | end | |
12 | ||
13 | local t = {} | |
14 | for j=0,f do | |
15 | table.insert(t, gb(i, j)) | |
16 | end | |
17 | ||
18 | return t | |
19 | end | |
20 | end | |
21 | ||
22 | local realquery = db_query | |
23 | ||
24 | function db_query(x, fn, t) | |
25 | if not fn then | |
26 | realquery(x) | |
27 | elseif not t then | |
28 | realquery(x, fn, nil) | |
29 | else | |
30 | realquery(x, fn, t) | |
31 | end | |
32 | end |