Jump to content

[c++] mysql select function


Recommended Posts

Hi everybody,

 

I want do function in game source ( mysql query select )

 

my function

    int _mysql_query_select( lua_State* L ){
        SQLMsg *msg = DBManager::instance().DirectQuery(lua_tostring(L, 1));

        if (msg->uiSQLErrno != 0)
            return 0;
    
        MYSQL_RES *res = msg->Get()->pSQLResult;
    
        MYSQL_ROW row = mysql_fetch_row(res);
    
        if (!row)
            return 0;

        lua_pushstring(L, row);
        
        return 1;
    }

error


questlua_global.cpp: In function 'int quest::_mysql_query_select(lua_State*)':
questlua_global.cpp:1207: error: cannot convert 'char**' to 'const char*' for argument '2' to 'void lua_pushstring(lua_State*, const char*)'

:(

 

 

  • Love 1
Link to comment
Share on other sites

  • Honorable Member

Is any way to get result from query without loop?

You have to convert the result to something acceptable for lua. Mine does it.

If you need something in particular, just write the complete request here.

NB: In your code, you're trying to push the list of all the fields of your row as string. (this is clearly not possible using a direct way like yours)

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.