SA-MP Forums Archive
[MYSQL] Problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [MYSQL] Problem (/showthread.php?tid=548214)



[MYSQL] Problem - Starve - 28.11.2014

Hi guys )
I have problem with that:
Код:
CMD:delete(playerid, params[]) {
	if(isnull(params))
	{
		SendClientMessage(playerid, COLOR_RED, "[ERROR] Use: "CWHITE"/delete [ID]");
		return 1;
	}
	
	new id = strval(params);
	format(query, sizeof(query), "SEELCT `UID` FROM `mapa_shop` WHERE `UID` = '%d'",id);
	mysql_query(query);
	if(!mysql_num_rows())
	{
		format(dstring,sizeof(dstring),"[ERROR] The database does not have a shop with UID:"CWHITE" %d",id);
		SendClientMessage(playerid, COLOR_RED, dstring);
		return 1;
	}
	ReloadShop();
	format(query, sizeof(query), "DELETE FROM `mapa_shop` WHERE `UID` = '%d'",id);
	mysql_query(query);
	return 1;
}
I don't know how to check, if the UID of the shop exists in the database. If not the server shows error. Can you help me ?


Re: [MYSQL] Problem - Vince - 28.11.2014

I believe mysql_affected_rows/cache_affected_rows will return the number of rows deleted so there is no need to check beforehand.


Re: [MYSQL] Problem - Starve - 28.11.2014

So, how it might look ?