Get rank direct from mysql
#2

Ugly, unthreaded function:
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;
}
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
Reply


Messages In This Thread
Get rank direct from mysql - by ajwar - 09.03.2015, 12:53
Re: Get rank direct from mysql - by Misiur - 09.03.2015, 13:25

Forum Jump:


Users browsing this thread: 1 Guest(s)