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