mysql_tquery - No callback specified, skipping result saving -
Jonesy96 - 01.06.2016
Hi all,
I'm new with the MySQL threaded queries, however I've been working my way through things. I am using the latest up to date version of BlueG's MySQL. I have a function called LoadUserData. Unfortunately, I'm unable to retrieve the result from the database without passing through a callback to mysql_tquery. Code is below:
Код:
forward LoadUserData(playerid, dbid);
public LoadUserData(playerid, dbid){
//this stock takes the ID passed to it and queries the user table
//it then stores info in the player enum
new query[128], rows, fields;
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `user` WHERE `id` = %i LIMIT 1;", dbid);
mysql_tquery(mysql, query);
cache_get_data(rows, fields, mysql);
if(rows){
User[playerid][id] = cache_get_field_content_int(0, "id"); //user id
cache_get_field_content(0, "username", User[playerid][username], mysql, 24); //username
User[playerid][id] = cache_get_field_content_int(0, "level"); //level
User[playerid][pass] = 0; //password..never going to need this really so overwritten
cache_get_field_content(0, "timestamp", User[playerid][timestamp], mysql, 10); //timestamp
GetPlayerIp(playerid, User[playerid][ip_address], 16); //set ip address
return true;
}else{
SendClientMessage(playerid, COLOR_RED, "--------------------------------------------------------");
SendClientMessage(playerid, COLOR_RED, "An error occurred loading user information. Please try again.");
SendClientMessage(playerid, COLOR_RED, "If the problem persists, contact system administrators.");
SetTimerEx("DelayedKick", 1000, false, "i", playerid);
return false;
}
}
My MySQL log is giving me the following error:
Код:
[18:35:02] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
I realise obviously that the results aren't being saved into the cache...but how do I fix that, so I can retrieve the data there? Should I be using mysql_query instead? Or is there a way to do this with mysql_tquery?
Many thanks.
Re: mysql_tquery - No callback specified, skipping result saving -
Konstantinos - 01.06.2016
It's neither an error, nor a warning. As you have enabled debug mode, it just says that the mysql_tquery hasn't a callback specified which in case of INSERT, UPDATE or DELETE would be fine but on SELECT you must always specify a callback.
pawn Код:
mysql_tquery(connectionHandle, query[], callback[] = "", format[] = "", {Float,_}:...);
So let's say you want to retrieve the data after executing the query in a callback called "OnPlayerDataLoad". That'd be:
pawn Код:
mysql_tquery(mysql, "SELECT ...", "OnPlayerDataLoad", "i", playerid);
which the callback has one parameter and that is an integer. Calling the cache functions directly without an active cache or not to the callback specified will give no active cache warning.
Here's an example script to take a look at, if you are interested:
https://github.com/pBlueG/SA-MP-MySQ...stem-cache.pwn
One last note, using debug log will slow down the queries and honestly you do not needed at all. Don't call
mysql_log so by default errors and warnings will be written in a file - that's all you need.
Re: mysql_tquery - No callback specified, skipping result saving -
Misiur - 01.06.2016
This is an example of threaded (non-lagging) way:
pawn Код:
forward LoadUserData(playerid, dbid);
public LoadUserData(playerid, dbid){
//this stock takes the ID passed to it and queries the user table
//it then stores info in the player enum
new query[128], rows, fields;
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `user` WHERE `id` = %i LIMIT 1;", dbid);
mysql_tquery(mysql, query, "OnUserDataLoaded", "d", playerid);
}
forward OnUserDataLoaded(playerid);
public OnUserDataLoaded(playerid) {
if(!cache_get_row_count(mysql)) {
SendClientMessage(playerid, COLOR_RED, "--------------------------------------------------------");
SendClientMessage(playerid, COLOR_RED, "An error occurred loading user information. Please try again.");
SendClientMessage(playerid, COLOR_RED, "If the problem persists, contact system administrators.");
SetTimerEx("DelayedKick", 1000, false, "i", playerid);
return false;
}
User[playerid][id] = cache_get_field_content_int(0, "id"); //user id
cache_get_field_content(0, "username", User[playerid][username], mysql, 24); //username
User[playerid][id] = cache_get_field_content_int(0, "level"); //level
User[playerid][pass] = 0; //password..never going to need this really so overwritten
cache_get_field_content(0, "timestamp", User[playerid][timestamp], mysql, 10); //timestamp
GetPlayerIp(playerid, User[playerid][ip_address], 16); //set ip address
return true;
}
Re: mysql_tquery - No callback specified, skipping result saving -
Jonesy96 - 01.06.2016
Thank you both very much. Understand all that now and fixed my issue