[Help] BlueG's MySQL Plugin R7 - Threaded Queries - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Help] BlueG's MySQL Plugin R7 - Threaded Queries (
/showthread.php?tid=386061)
[Help] BlueG's MySQL Plugin R7 - Threaded Queries -
Maxips2 - 18.10.2012
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?
Re: [Help] BlueG's MySQL Plugin R7 - Threaded Queries -
ReneG - 18.10.2012
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.
Re: [Help] BlueG's MySQL Plugin R7 - Threaded Queries -
Maxips2 - 18.10.2012
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.
Re: [Help] BlueG's MySQL Plugin R7 - Threaded Queries -
ReneG - 19.10.2012
Ignore the php tags.
PHP Code:
#define THREAD_REGISTER 5
enum pInfo
{
pSQLid
}
new PlayerInfo[MAX_PLAYERS][pInfo];
stock CreateAccount(playerid, pass[])
{
new
query[200],
name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(query, sizeof(query), "INSERT INTO `users` (name, pass) VALUES (\'%s\', \'%s\')", name, pass);
mysql_function_query(connectionHandle, query, false, "OnQueryFinish", "dd", THREAD_REGISTER, playerid);
return 1;
}
forward OnRegisterQueryFinish(resultid, extraid);
public OnRegisterQueryFinish(resultid, extraid)
{
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.
Re: [Help] BlueG's MySQL Plugin R7 - Threaded Queries -
Maxips2 - 19.10.2012
I actually tried that before you replied and it worked, thank you a lot !