Count total accounts
#1

Help:

Код HTML:
 new Cache: cachecheck = mysql_query(handle, "SELECT COUNT(playerID) from playeraccounts");
	numberaccounts = cache_get_row_count();
	cache_delete(cachecheck);
The result will be 1. What's wrong?
Reply
#2

Quote:
Originally Posted by Nin9r
Посмотреть сообщение
Help:

Код HTML:
 new Cache: cachecheck = mysql_query(handle, "SELECT COUNT(playerID) from playeraccounts");
	numberaccounts = cache_get_row_count();
	cache_delete(cachecheck);
The result will be 1. What's wrong?
Well, I didn't use count so far but this supposed to.work:
Код HTML:
 new Cache: cachecheck = mysql_query(handle, "SELECT null from playeraccounts");
	numberaccounts = cache_get_row_count();
	cache_delete(cachecheck);
Reply
#3

It works, thank you so much ! +rep
Reply
#4

I would suggest you to use select count(*) instead of selecting all rows because it may affect your script performance or may hangs your server (as i see you're using unthreaded query) if the table have many rows.
Here's an example to get total rows:
Код:
	new Cache:cachecheck = mysql_query(handle, "SELECT COUNT(playerID) AS total from playeraccounts");
	numberaccounts = cache_get_field_content_int(0, "total");
	cache_delete(cachecheck);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)