diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/LuaSQL.cc | 18 | ||||
-rw-r--r-- | lib/SQL.cc | 2 |
2 files changed, 13 insertions, 7 deletions
diff --git a/lib/LuaSQL.cc b/lib/LuaSQL.cc index 2563ff6..a5b2dce 100644 --- a/lib/LuaSQL.cc +++ b/lib/LuaSQL.cc @@ -111,13 +111,17 @@ int sLua_SQLConnection::SQLConnection_proceed(Lua * L, int n, SQLConnection * c, L->push((lua_Number) c->numfields()); break; case SQLCONNECTION_FETCHROW: - r = c->fetchrow(); - L->newtable(); - for (i = r.begin(); i != r.end(); i++) { - L->push(i->first); - L->push(i->second); - L->settable(); - } + if (c->numrows()) { + r = c->fetchrow(); + L->newtable(); + for (i = r.begin(); i != r.end(); i++) { + L->push(i->first); + L->push(i->second); + L->settable(); + } + } else { + L->push(); + } break; case SQLCONNECTION_NUMAFFECTEDROWS: L->push((lua_Number) c->numaffectedrows()); @@ -100,6 +100,8 @@ AssocArray SQLConnection::fetchrow() { for (i = 0; i < nf; i++) { r[fields[i].name] = row[i] ? row[i] : "NULL"; } + + nf--; } return r; |