diff options
author | Pixel <pixel@nobis-crew.org> | 2008-10-03 11:44:20 -0700 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2008-10-03 11:44:20 -0700 |
commit | 65430bb471aef183e13c05466a4068e7f1b8d8fc (patch) | |
tree | 1d05b3bf8179779ce4548dc89034dcbb7db9b020 | |
parent | d977ac60cf001e9bfa27fc7b2dcc357af9771e6f (diff) |
Returning nil on 'FetchRow' if we don't have any more row to return.
-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; |