Jump to content
  • 0

[c++] mysql select function


ekoo

Question

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

3 answers to this question

Recommended Posts

  • 0
  • 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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • 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.