Raised This Month: $ Target: $400
 0% 

Threaded query


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
sparkey
Senior Member
Join Date: May 2010
Old 10-14-2010 , 07:13   Threaded query
Reply With Quote #1

Hey,

I have about 4000 rows of code where i have been using the old fashion sqlx way. I have now been experiencing alot of lag on the servers due to our population and i need to migrate into threaded queries.

I have been playing around and read here on the forum but cant for some reason make it work. I have a global variable outside the function which i tries to set in the threaded sql function but i cant get it to work.

No errors when compiling it just does not store the data in the specified variable.

PHP Code:
    formatex(mysqlIp127"SELECT id,port FROM %s WHERE ip = '%s' LIMIT 1"MYSQL_SERVER_TABLEip);
    
SQL_ThreadQuery(g_SqlTuple"QueryStartup"mysqlIpip21);

 
public 
QueryStartup(FailState,Handle:query,Error[],Errcode,ip[],DataSize)
{
    if (
FailState == TQUERY_CONNECT_FAILED)
    {
        
log_amx("[%s]%s Error connecting to SQL: %s (%s)"log_time(), SERVER_PREFIXErrorErrcode);
        return;
    }
    if (
FailState == TQUERY_QUERY_FAILED)
    {
        
log_amx("[%s]%s Error executing Query: %s (%s)"log_time(), SERVER_PREFIXErrorErrcode);
        return;
    }
    if(!
SQL_Execute(query))
    {
        
log_amx("[%s]%s Error executing Query: %s (%s)"log_time(), SERVER_PREFIXErrorErrcode);
        return;
    }
    if (
SQL_NumResults(query))
    {
        
log_amx("[%s]%s Error Could not find a server with the address %s."log_time(), SERVER_PREFIXip);
    }
    
serverid SQL_ReadResult(query0);
    
ghost_port SQL_ReadResult(query1);
    
log_amx("[%s]%s OK! Fetched the address %s."log_time(), SERVER_PREFIXip);

Any help is appriciated.
sparkey is offline
 


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

Forum Jump


All times are GMT -4. The time now is 10:22.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode