[MySQL] Return function
is there any way i can return integer values or text according to a query?
we usually do this PHP Code:
return straight into function PHP Code:
like PHP Code:
|
Re: [MySQL] Return function
Instead of using SQL_ThreadQuery, use SQL_Execute. You will.need to prepare the query using Sql_PrepareQuery
|
Re: [MySQL] Return function
Quote:
Threaded queries are better to use in a live game for this reason, but due to their asynchronous nature, one can not do what OP wants because when the SQL_ThreadQuery returns there is no guarantee the query was actually executed. The callback is meant to serve as a notification that the query is done and results are available. |
Re: [MySQL] Return function
Quote:
does this make no sense here? PHP Code:
|
Re: [MySQL] Return function
Quote:
No, it won't work, because the callback is executed after the SqlGetUserIndex() function ends. Test it by yourself by adding debug messages. PHP Code:
|
Re: [MySQL] Return function
No, it is not correct. Let me try to explain again using your code:
PHP Code:
|
Re: [MySQL] Return function
Quote:
haven't tested it, would that work?: PHP Code:
|
Re: [MySQL] Return function
No, because immediately after calling SqlGetUserIndex(), you are expecting to have the return value from the threaded query. As HamletEagle said, the query is asynchronous, meaning you can think if it as being added to a queue and executed when resources are available. You cannot expect results to be immediately available.
PHP Code:
|
Re: [MySQL] Return function
Quote:
|
Re: [MySQL] Return function
Not sure what the standard method means, but you want to avoid using an execute query as it will cause lags, if this is what you are referring to.
I gave you an idea in my code snippet. You can execute the handler function once the result is determined: Code:
|
| All times are GMT -4. The time now is 11:44. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.