Check records in mysql
#2

you use mysql_tquery to send the query and then on the callback you use cache_num_rows() to get the number of rows.

Example from Wiki
Код:
forward OnPlayerDataLoaded(playerid);
 
public OnPlayerConnect(playerid)
{
	new query[128], pname[MAX_PLAYER_NAME];
	new array[10] = {1, 2, ...};
 
	GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
 
	mysql_format(MySQL, query, sizeof(query), "SELECT * FROM `players` WHERE `name` LIKE '%e'", pname);
	mysql_tquery(MySQL, query, "OnPlayerDataLoaded", "dad", playerid, array, sizeof array);
	return 1;
}
 
public OnPlayerDataLoaded(playerid, array[], array_size)
{
	//Query processed, you can now execute cache functions (like cache_get_value_index) here.
	printf("There are %d players with the same name.", cache_num_rows());
	return 1;
}
Reply


Messages In This Thread
Check records in mysql - by Oficer - 21.02.2018, 19:51
Re: Check records in mysql - by Kaperstone - 21.02.2018, 20:07

Forum Jump:


Users browsing this thread: 1 Guest(s)