Question about MySQL
#1

I was looking at a tutorial for a register/login system that was made with the latest version of MySQL and noticed within the player enum was something called Cache_ID. I'm just curious what the benefit of that is as I can't seem to find what it's use is for, even after looking through the tutorial.
Reply
#2

Can be used for save data you received from mysql query. For example, you can use query, save cache, and use it in another code place without next query.
Reply
#3

Is there a small example that I could see to understand it a bit better?
Reply
#4

1. Player enum:

Cache: Cache_ID

2. Query:

Код:
mysql_format(g_SQL, query, sizeof query, "SELECT * FROM `players` WHERE `username` = '%e' LIMIT 1", Player[playerid][Name]);
mysql_tquery(g_SQL, query, "OnPlayerDataLoaded", "dd", playerid, g_MysqlRaceCheck[playerid]);
3. OnPlayerDataLoaded (loading password only):

Код:
cache_get_value(0, "password", Player[playerid][Password], 65);
and saving cache:

Код:
Player[playerid][Cache_ID] = cache_save();
4. Now you can use data from our query in other place of code, no more need to mysql_tquery. So we are loading rest by this code:

Код:
cache_set_active(Player[playerid][Cache_ID]);
cache_get_value_int(0, "kills", Player[playerid][Kills]);
5. No need that data anymore? Delete cache.

Код:
cache_delete(Player[playerid][Cache_ID]);
Player[playerid][Cache_ID] = MYSQL_INVALID_CACHE;
Reply
#5

Oh alright, that makes sense. Thanks for the help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)