[Help] BlueG's MySQL Plugin R7 - Threaded Queries
#1

Hey there,

I've been working on converting my game mode to the new R7 version but I got an issue with threaded queries.

I have some functions which retreive data from MySQL and return the result.
Is there any way to do it with threaded queries?
Reply
#2

You can't return values anymore with threaded queries, you can pass parameters though, and put the code in the callback. Tell me exactly what you are trying to do and I can show you an example.
Reply
#3

Well it really bothers me with registration, when I insert a new row to the table I need to reterive the insert id by using mysql_insert_id, and return that id and work with it later.
Reply
#4

Ignore the php tags.
PHP Code:
#define   THREAD_REGISTER   5
enum pInfo
{
    
pSQLid
}
new 
PlayerInfo[MAX_PLAYERS][pInfo];
stock CreateAccount(playeridpass[])
{
    new 
        
query[200],
        
name[MAX_PLAYER_NAME];
    
    
GetPlayerName(playeridnamesizeof(name));
    
format(querysizeof(query), "INSERT INTO `users` (name, pass) VALUES (\'%s\', \'%s\')"namepass);
    
    
mysql_function_query(connectionHandlequeryfalse"OnQueryFinish""dd"THREAD_REGISTERplayerid);
    return 
1;
}
forward OnRegisterQueryFinish(resultidextraid);
public 
OnRegisterQueryFinish(resultidextraid)
{
    switch(
resultid) {
        case 
THREAD_REGISTER: {
            
PlayerInfo[extraid][pSQLid] = mysql_insert_id();
            
            
SendClientMessage(extraid, -1"You have registered.");
        }
    }
    return 
1;

though I'm not sure if mysql_insert_id() will return something else with a lot of queries being run at once, but it works for me.
Reply
#5

I actually tried that before you replied and it worked, thank you a lot !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)