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(mysqlIp, 127, "SELECT id,port FROM %s WHERE ip = '%s' LIMIT 1", MYSQL_SERVER_TABLE, ip);
SQL_ThreadQuery(g_SqlTuple, "QueryStartup", mysqlIp, ip, 21);
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_PREFIX, Error, Errcode);
return;
}
if (FailState == TQUERY_QUERY_FAILED)
{
log_amx("[%s]%s Error executing Query: %s (%s)", log_time(), SERVER_PREFIX, Error, Errcode);
return;
}
if(!SQL_Execute(query))
{
log_amx("[%s]%s Error executing Query: %s (%s)", log_time(), SERVER_PREFIX, Error, Errcode);
return;
}
if (SQL_NumResults(query))
{
log_amx("[%s]%s Error Could not find a server with the address %s.", log_time(), SERVER_PREFIX, ip);
}
serverid = SQL_ReadResult(query, 0);
ghost_port = SQL_ReadResult(query, 1);
log_amx("[%s]%s OK! Fetched the address %s.", log_time(), SERVER_PREFIX, ip);
}
Any help is appriciated.