Thread: [Solved] [MySQL] Return function
View Single Post
wilian159
Member
Join Date: Dec 2013
Old 01-09-2022 , 09:56   Re: [MySQL] Return function
Reply With Quote #4

Quote:
Originally Posted by HamletEagle View Post
You should mention that this will execute the queries in synchronous/blocking mode which will block the main thread until the query is completed. Generally, this isn't something you want to do.

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.
so there's no way to do what I want?


does this make no sense here?

PHP Code:
new VarTest

public SqlGetUserIndex(id)
{
    
SQL_ThreadQuery(handle"_SqlGetUserIndex""SELECT id FROM users WHERE authid = 'STEAM_XXXXXXXX'")

    return 
VarTest
}

public 
_SqlGetUserIndex(fail_stateHandle:queryerror[], error_codedata[], data_size)
{
    
// check fails, etc....

    
if(SQL_NumResults(query))
    {
        
VarTest SQL_ReadResult(xQuery0)
    }
    else
    {
        
VarTest = -1
    
}

__________________

Last edited by wilian159; 01-09-2022 at 10:02.
wilian159 is offline