09.03.2015, 13:25
Ugly, unthreaded function:
Don't call this function often, unthreaded queries are really rarely necessary. Use inline handling if you want to keep your logic together, but still use threaded version
pawn Код:
GetIDRank(id)
{
new
query[128],
value
;
mysql_format(handle, query, sizeof query, "SELECT COUNT(id) AS rank FROM <tablename> WHERE Score >= (SELECT Score FROM <tablename> WHERE id = %d)", id);
new Cache:result = mysql_query(MySQL, query);
value = cache_get_row_count(handle) ? cache_get_field_content_int(0, "rank", handle) : -1;
cache_delete(result);
return value;
}