]> jfr.im git - irc/quakenet/newserv.git/blobdiff - lua/lib/db.lua
LUA: port luadb to dbapi2 to drop postgres dependency
[irc/quakenet/newserv.git] / lua / lib / db.lua
index 6bcf90e63233ce2a97155fc05d94cbe66e0a14e9..d86f8bf5799e580a274b58304c703c0dc17a3efc 100644 (file)
@@ -1,21 +1,19 @@
 function db_queryiter()
-  local c = db_numrows()
-  local i = -1
-  local f = db_numfields()
+  local f = db_numfields() - 1
   local gb = db_getvalue
 
   return function()
-    i = i + 1
-    if i == c then
+    if not db_nextrow() then
       return nil
     end
 
     local t = {}
     for j=0,f do
-      table.insert(t, gb(i, j))
+      local v = gb(j)
+      table.insert(t, v)
     end
 
-    return t
+    return unpack(t)
   end
 end