View Single Post
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 07-26-2007 , 02:50   Re: SQLx Select Handle Help plz
Reply With Quote #8

Thanks for the replies.

@Minimum:
I'm trying to use the threaded query not the prepare query. Threaded queries are better to use right?

Also I think I might be on to something but it doesn't seem to be working...
SQL_ThreadQuery ( Handle:cn_tuple, const handler[], const query[], const data[]=0 )

That data should be sent to the handler...
public QueryHandler(failstate, Handle:query, error[], errnum, data[], size)

Here is an example that doesn't return the data I sent.
PHP Code:
public function()
{
    new 
authid[33];
    
get_user_authid(idauthid32);
    
    
format(g_Cache511"SELECT * FROM players WHERE steamid='%s'"authid);
    
SQL_ThreadQuery(g_SqlTuple"SelectHandle"g_Cache"Test");
    
    return 
FMRES_HANDLED;
}

public 
SelectHandle(FailStateHandle:QueryError[], ErrcodeData[], DataSize)
{
    if(
FailState == TQUERY_CONNECT_FAILED)
            return 
set_fail_state("Could not connect to SQL database.");
    else if(
FailState == TQUERY_QUERY_FAILED)
            return 
set_fail_state("Query failed.");
    
    if(
Errcode)
        return 
log_amx("Error on query: %s"Error);
    
    
// Shouldn't this display "Test" because it's the data that was sent?
    // Instead it displays a blank line.
    
client_print(0print_chat"%s"Data);
    
    return 
PLUGIN_CONTINUE;

hlstriker is offline