PDA

View Full Version : cache_get_value...


GoldenLion
16/12/2016, 12:51 PM
Hi, what's the difference between cache_get_value and cache_get_value_name, cache_get_value_int and cache_get_value_name_int and so on in MySQL?

DetoNater
16/12/2016, 01:38 PM
Its the function which fetches the data stored by your query..... name means string, obiously, int means integer amd so on.... just check some example code's usage somewhere and u'll know the purpose of usage then..

you can check wiki here http://wiki.sa-mp.com/wiki/MySQL/R40

GoldenLion
16/12/2016, 01:40 PM
I know what they are for, but I'm asking the difference between them.
cache_get_value
cache_get_value_name
cache_get_value_int
cache_get_value_name_int
cache_get_value_float
cache_get_value_name_float

Vince
16/12/2016, 01:44 PM
One gets the results by column index (0, 1, 2, ...) the other gets them by name ("id", "name", "level", ...).

Konstantinos
16/12/2016, 01:53 PM
cache_get_value_index gets the results by column index whereas cache_get_value (macro) accepts both column index or column name.

GoldenLion
16/12/2016, 01:56 PM
Right, but there are 3 of them like cache_get_value_index, cache_get_value_name, cache_get_value. What's the difference between cache_get_value_name and cache_get_value?

Runn3R
16/12/2016, 08:03 PM
There is no cache_get_value. Atleast no in the mysql wiki: (click the fnames for the wiki page)

cache_get_value_name (http://wiki.sa-mp.com/wiki/MySQL/R40#cache_get_value_name):
cache_get_value_name(0, "name", dest);
Selects a row by a column name and loads it into the destination array(in this case).

cache_get_value_index (http://wiki.sa-mp.com/wiki/MySQL/R40#cache_get_value_index):
Selects a row by a column number and loads it into the destination array(in this case).
cache_get_value_index(0, 0, dest);


Performance wise the index one is faster hence it doesn't need to check the column name and compare it to what did you type in. But the index is way messy.

GoldenLion
16/12/2016, 08:46 PM
There is no cache_get_value.
https://github.com/pBlueG/SA-MP-MySQL/blob/master/example_scripts/login_system-cache.pwn - that's MySQL R40.

Runn3R
16/12/2016, 08:56 PM
It's probably a macro or a redefinition.

Try adding cache_get_value_int and it will work just as cache_get_value_name_int

Runn3R
17/12/2016, 12:40 PM
cache_get_value is just a comfort function (macro actually). Based on the input parameters you provide, it automatically resolves to cache_get_value_name or cache_get_value_index, e.g.:

cache_get_value(0, 0, data); // translates to cache_get_value_index
cache_get_value(0, "field", data); // translates to cache_get_value_name

new idx;
cache_get_value(0, idx, data); // translates to cache_get_value_index

new field[32] = "field2";
cache_get_value(0, string:field, data); // translates to cache_get_value_name



Just a macro.

Misiur
17/12/2016, 12:58 PM
https://github.com/pBlueG/SA-MP-MySQL/blob/ad80a15cc0660694bb17bd68cee52b88ef9940a9/a_mysql.inc.in#L200-L203

cache_get_value resolves to either cache_get_value_index or cache_get_value_name

GoldenLion
17/12/2016, 01:12 PM
Thanks.