MySQL, rows checking. - 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, rows checking. (
/showthread.php?tid=514787)
MySQL, rows checking. -
Denying - 23.05.2014
Uh, hi there.
I want to check how many rows I have in.. let's say my accounts table, that should give me the amount of registered players, I believe.
I'm not quite sure how to do it, I tried asking ****** first, but since I am asking it here as well, you can only assume I did not find an answer to my question.
Thanks in advance.
Re: MySQL, rows checking. -
BroZeus - 23.05.2014
learn to ****** first
use mysql_num_rows() function after storing the result which will return number of rows
Re: MySQL, rows checking. -
Denying - 23.05.2014
I did that, it said these functions aren't defined. I have the MySQL include etc. I don't see what the problem is.
Re: MySQL, rows checking. -
kamiliuxliuxliux - 23.05.2014
Which version of MySQL are you using?
Re: MySQL, rows checking. -
Denying - 23.05.2014
MySQL R33, ye, I checked around and it seems I need MySQL R7? I'm downloading it.
EDIT: Can't seem to find a proper download link, anywhere. Not even on the official post. -.-
Re: MySQL, rows checking. -
kamiliuxliuxliux - 23.05.2014
It's not so nessesary, just call a callback with the query execution (use threaded query)
pawn Код:
// Example:
public OnPlayerConnect(playerid)
{
mysql_tquery(1, "SELECT * FROM accounts WHERE name = 'myname'", "LoadPlayerData", "i", playerid);
return 1;
}
forward LoadPlayerData(playerid);
public LoadPlayerData(playerid)
{
//now here you can use cache functions as cache_num_rows(); which means the same thing as mysql_num_rows
return 1;
}
+rep if helped
Re: MySQL, rows checking. -
Denying - 23.05.2014
Thank you, kamili, +rep.
Re: MySQL, rows checking. -
kamiliuxliuxliux - 23.05.2014
I tried to do something with mysql_num_rows() and I didn't recieve any errors. O.o
Re: MySQL, rows checking. -
Vince - 23.05.2014
Using the inbuilt
COUNT() function is probably faster than calling mysql_num_rows, since much less information will be transmitted and stored in memory.