SA-MP Forums Archive
MySQL Retrieve field - 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 Retrieve field (/showthread.php?tid=454876)



MySQL Retrieve field - saamp - 30.07.2013

I have a database with 10 rows and 30 fields. I want to go on each row, and to get the fieldName 'pName' and to print it. Is there any efficient function rather that this?

Код:
	mysql_query("SELECT `pName` FROM `database`");
	mysql_store_result();

	new registeredPlayers = mysql_num_rows();

	if(registeredPlayers)
	{
		new pName[MAX_PLAYER_NAME];
		while(mysql_retrieve_row())
		{
			mysql_get_field("playerName", pName);
			printf("%s", pName);
		}
	}

	mysql_free_result();

	printf("Total registered players: %d", registeredPlayers);



Re: MySQL Retrieve field - Sinner - 30.07.2013

Quote:
Originally Posted by saamp
Посмотреть сообщение
I have a database with 10 rows and 30 fields. I want to go on each row, and to get the fieldName 'pName' and to print it. Is there any efficient function rather that this?

Код:
	mysql_query("SELECT `pName` FROM `database`");
	mysql_store_result();

	new registeredPlayers = mysql_num_rows();

	if(registeredPlayers)
	{
		new pName[MAX_PLAYER_NAME];
		while(mysql_retrieve_row())
		{
			mysql_get_field("playerName", pName);
			printf("%s", pName);
		}
	}

	mysql_free_result();

	printf("Total registered players: %d", registeredPlayers);
Use the latest MySQL plugin? Threaded queries are a lot more efficient.


Re: MySQL Retrieve field - saamp - 30.07.2013

Quote:
Originally Posted by Sinner
Посмотреть сообщение
Use the latest MySQL plugin? Threaded queries are a lot more efficient.
Yes, I think! Could you show me an example?


Re: MySQL Retrieve field - Sinner - 30.07.2013

https://sampforum.blast.hk/showthread.php?tid=337810