SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Discussion

Reply
 
Thread Tools Display Modes
Old 16/12/2017, 04:13 AM   #11
Kaperstone
Banned
 
Join Date: May 2011
Location: Russia
Posts: 3,338
Reputation: 824
Default Re: How do you name MySQL threaded queries?

There is no "safer" in parameters.

You use them when you want to pass data from one event to another.


You can get scenario of Client B receiving event A and event B, and Client A receiving A and B.
This all depends upon your code.

The callback is just an event, the callback just fires, it has no target player or anything else.
You can use it however you wish, if you don't pass playerid, then you won't know who the query belongs to.

The extra parameters are just so you could continue the flow with your previous data.
Kaperstone is offline   Reply With Quote
Old 16/12/2017, 12:43 PM   #12
RIDE2DAY
Huge Clucker
 
RIDE2DAY's Avatar
 
Join Date: Jul 2015
Location: Modena, Italy
Posts: 220
Reputation: 375
Default Re: How do you name MySQL threaded queries?

@Meller, @Kaperstone: yes, that's what I was trying to say. Let's see if Y_Less clarifies this out.
RIDE2DAY is offline   Reply With Quote
Old 16/12/2017, 01:18 PM   #13
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 15,309
Reputation: 3191
Default Re: How do you name MySQL threaded queries?

OK, a clarification. When you call "Callback_Get" (which is called within the mysql_inline_query function (or whatever it is called - you know what I mean)), it stores the address of the function and all the local variables at the current time. When the callback is invoked, all the locals are restored. If you create two queries, two copies of the locals are stored. This copy of the locals is called a "closure".

The two are totally separate. You could make many queries in a loop, and when each one was called the loop variable would be whatever it was at query time. So 10 queries in a loop, 10 different future values of "i".

This is also why "Callback_Release" is required (but again, I think that is handled internally in the mysql include), to free up the memory used by the closure.
Y_Less is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial] MySQL Threaded queries with y_inline Jay_ Tutorials 20 22/01/2017 07:03 PM
Mysql threaded queries. ScIrUsna Scripting Help 1 18/03/2016 08:22 AM
MySQL Help - Threaded Queries. Lynn Scripting Help 3 09/01/2015 08:44 PM
MySQL Threaded Queries CONTROLA Scripting Help 4 25/11/2012 04:02 PM


All times are GMT. The time now is 11:09 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.