Threaded query
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:
|
Re: Threaded query
'OK! Fetched the address'
is this message being printed? Any debugs? |
Re: Threaded query
Thanks for your answer.
It only reports errors for later functions that dont get the serverid and ghost_port. It does not print OK and it does not print Error so it seems that it does not even run the QueryStartup function :( |
Re: Threaded query
Using SQL_Execute with threaded queries is wrong.
QueryStartup function is not a startup for query. You start query when you call SQL_ThtreadQuery. When QueryStartup function is called, it means that you have already received reply from sql database. Check this complete example (it's using sqlite, but it's really easy to convert it to mysql): http://forums.alliedmods.net/showthr...66#post1204466 |
Re: Threaded query
fantastic, works like a charm.
Let me just ask so i got this straight. If i for example executes the threadquery it runs on its own thread the the code itself continues to run? If i for example does this and tries to print the variable that i sets in the QueryStartup function directly after the SQL_ThreadQuery it wont print? So i have to do all the comparing in the SQL_ThreadQuery function? PHP Code:
PHP Code:
|
Re: Threaded query
You are right. The query runs in its own thread, and it won't print variable directly after SQL_ThreadQuery. You need to do the comparison and print it in QueryStartup function.
Also you don't need to check twice for errors: PHP Code:
PHP Code:
|
Re: Threaded query
Alright i see :)
Thanks alot m8! Got alot of rewrite to do but eventually it will be great i hope. Thanks bigtime for your time and your help! |
| All times are GMT -4. The time now is 10:22. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.