FreeBSD LuaSQL - Mysql

05/11/2013 22:21 ionutxp#1
There is an way to install luasql-mysql in freebsd and get it to work with metin2 quest?

cd /usr/ports/databases/luasql-mysql && make clean install

It create mysql.so in usr/local/lib/lua/lua5.1 but i can't get it to wok. I have exhausted all options......

Thx.

PS: I will be happy if someone have this function completed:
PHP Code:
int mysql_do_query(int *luabp)
{
    
int *result, *p_res, i=0;
    
MYSQL_FIELD *field;
    
char *query, **row;
    
unsigned long long int num = 0;
    
    
query = lua_tostring(luabp,1);
    
result = (int *)DirectQuery(*DBManager, query);
    
p_res = *(int**)result[3];

    if (!*
p_res) {
        
lua_pushnumber(luabp, 0);
        return 
0;
    }
    
lua_newtable(luabp);
    while(
row = mysql_fetch_row(*p_res)) {
        while( 
field = (MYSQL_FIELD*)mysql_fetch_field(*p_res) ) {
            
lua_pushstring(luabp,field->name);
            if (
sscanf(row[i],"%llu", &num)) 
                
lua_pushnumber(luabp, num * 1.0);
            else 
                
lua_pushstring(luabp,row[i]);
            
lua_rawset(luabp, -3);
            
i++;            
        }
    }
    return 
1;
} 
It should work like this:

PHP Code:
local result = sql.query("SELECT id, name FROM users;");
say(result[1].name)
say(result[3].name)
say(result[4].name)
But it displays only one row: say(result.name) 
06/19/2013 19:12 .DerPade#2
Hey

Nice to see someone other is working on these things.

I'll give you a feedback if i know more :)

PS: Sorry for my bad english, I'm from switzerland.
06/20/2013 00:13 RedKing2#3
Why you install Lua sql?