MySQL Update
#1

Hello guys i have a question about mysql update from r6(i think) to r41
I have this 2 things:
Код:
public MySQLCheckCar(carname[])
{
	new query[128],escstr[MAX_PLAYER_NAME];
	mysql_real_escape_string(carname, escstr);
	format(query, sizeof(query), "SELECT `ID` FROM stock WHERE `Car` = '%s'", escstr);
	mysql_query(SQL,query);
	mysql_store_result();
	if (mysql_num_rows()==0)
	{
	    mysql_free_result();
		return 0;
	}
	else
	{
		new strid[32],intid;
		mysql_fetch_row(strid);
		intid = strval(strid);
	    mysql_free_result();
		return intid;
	}
}
Код:
public MySQLCheckCar(carname[])
{
	new query[64],intid;
	mysql_format(query, sizeof(query), "SELECT `ID` FROM stock WHERE `Car` = '%e'", carname);
	mysql_tquery(SQL,query, "", "");
	if(cache_num_rows() > 0)
	{
		cache_get_value_name_int(0, "ID",intid);
		return intid;
	}
}
They do same thing? Or i need to call mysql querry first and then get cache from it?(second one)
The function is called everytime an admin set a car to the stock....
I want to learn to update from that old functions to new one, for me of course, you don't know when you need....
Reply
#2

You need to call a callback when the query has finished running. Do this with the mysql_tquery function, for example
Код:
mysql_tquery(SQL,query, "CallBack");
and then

Код:
forward CallBack();
public CallBack()
{
     //fetch data here
Reply
#3

Oh...Thanks, i was not sure if i need to call the callback from tquery or not....Thanks again
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)