SA-MP Forums Archive
Retrive a string MySQL cache get field content - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Retrive a string MySQL cache get field content (/showthread.php?tid=605785)



Retrive a string MySQL cache get field content - NeXoR - 24.04.2016

Hey guys, according to SAMP WIKI MySQL (BlueG's)
Storing a string requires a string to store it inside
PHP код:
cache_get_field_content(0"name"dest); 
Can I do like ?
PHP код:
PlayerInfo[playerid][pName] = cache_get_field_content(0"name"); 



Re: Retrive a string MySQL cache get field content - jlalt - 24.04.2016

no but you can do
PHP код:
cache_get_field_content(0"name"PlayerInfo[playerid][pName]); 
also you can do

PHP код:
new dest[MAX_PLAYER_NAME];
cache_get_field_content(0"name"dest);
format(PlayerInfo[playerid][pName], MAX_PLAYER_NAME,dest); 



Re: Retrive a string MySQL cache get field content - NeXoR - 24.04.2016

Quote:
Originally Posted by jlalt
Посмотреть сообщение
no but you can do
PHP код:
cache_get_field_content(0"name"PlayerInfo[playerid][pName]); 
also you can do

PHP код:
new dest[MAX_PLAYER_NAME];
cache_get_field_content(0"name"dest);
format(PlayerInfo[playerid][pName], MAX_PLAYER_NAME,dest); 
I'll try the second one, btw I know its pretty lame but what does "row index" means ? (starting in 0, according to WIKI)


Re: Retrive a string MySQL cache get field content - jlalt - 24.04.2016

row index, for example when you do
PHP код:
SELECT FROM `ACCOUNTSWHERE `LEVEL` = '0' 
it will get the rows from latest guy registered with level 0 to oldest guy registered and has level 0 yet,
so if you do

PHP код:
cache_get_field_content(0"name"dest); 
it will get latest guy name but if you do
PHP код:
cache_get_field_content(mysql_num_rows()-1"name"dest); // -1 cause rows index start from 0 
it will get oldest guy name

so by that you can do a loop to get all players names which got level 0

PHP код:
for(new 0mysql_num_rows(); i++) {
   
cache_get_field_content(i"name"dest);  
   
printf(dest);




Re: Retrive a string MySQL cache get field content - NeXoR - 24.04.2016

Quote:
Originally Posted by jlalt
Посмотреть сообщение
row index, for example when you do
PHP код:
SELECT FROM `ACCOUNTSWHERE `LEVEL` = '0' 
it will get the rows from latest guy registered with level 0 to oldest guy registered and has level 0 yet,
so if you do

PHP код:
cache_get_field_content(0"name"dest); 
it will get latest guy name but if you do
PHP код:
cache_get_field_content(mysql_num_rows()-1"name"dest); // -1 cause rows index start from 0 
it will get oldest guy name

so by that you can do a loop to get all players names which got level 0

PHP код:
for(new 0mysql_num_rows(); i++) {
   
cache_get_field_content(i"name"dest);  
   
printf(dest);

So if I limit the query to 1 (LIMIT = 1)
I should use row 0 all the time, right ?


Re: Retrive a string MySQL cache get field content - jlalt - 24.04.2016

Quote:
Originally Posted by NeXoR
Посмотреть сообщение
So if I limit the query to 1 (LIMIT = 1)
I should use row 0 all the time, right ?
yea cause there just will be one row index


Re: Retrive a string MySQL cache get field content - NeXoR - 24.04.2016

Quote:
Originally Posted by jlalt
Посмотреть сообщение
yea cause there just will be one row index
Thank you!