I'm running a MySQL query which always returns 4 rows:
row->name, row->date, row->ip, row->custom
What I want to achieve is create a simple table basing on the above results so it would look like:
{
"name" = result of row->name,
"date" = result of row->date,
"ip" = result of row->ip,
"custom" = result of row->custom
}
I have tried multiple possibilities, but the examples posted are really varied and I got a problems making it working.
My last unsuccessful try:
lua_createtable(L, 0, 4);
top = lua_gettop(L);
lua_pushstring(L, "name");
lua_pushstring(L, row->name);
lua_pushstring(L, "date");
lua_pushnumber(L, row->date);
lua_pushstring(L, "ip");
lua_pushstring(L, row->ip);
lua_pushstring(L, "custom");
lua_pushstring(L, row->custom);
lua_settable(L, top);
lua_settable()sets only 1 value and pops only 1 pair of key, value from stack. Repeat it 4.