MySQL / Enumerator issue
#4

Often problems can be solved by re-writing your code.

This code is cleanly rewritten and doesn't fetch the row count over and over for looping. The query buffer length is 30 characters max, but you used 150. Although, the problem is not visible in the code you've presented, but why save everything when it is most probably not changed? Just save the data when it's changed, like if an admin (or clan leader) renames, then it saves the clan name only and doesn't otherwise.

PHP Code:
#define MAX_CLAN_NAME_LEN    (32)

forward LoadClans();
public 
LoadClans() {

    new
        
query[45];

    
mysql_format(Databasequerysizeof query"SELECT * FROM `clans` LIMIT %i"MAX_CLANS);
    
mysql_tquery(Databasequery"OnClansLoad");
    return 
1;
}

forward OnClansLoad();
public 
OnClansLoad() {

    new
        
rows;

    
cache_get_row_count(rows);

    if(!
rows)
        
printf("[SERVER]: No clans were loaded from the MySQL Database.");

    for(new 
0!= rows++) {

        
cache_get_value_name_int(i"ClanID"ClanInfo[i][ClanID]);
        
cache_get_value_name(i"ClanName"ClanInfo[i][ClanName]);
        
cache_get_value_name(i"ClanLeader"ClanInfo[i][ClanLeader]);
        
cache_get_value_name_int(i"ClanColor"ClanInfo[i][ClanColor]);
        
cache_get_value_name_int(i"ColorSet"ClanInfo[i][ColorSet]);
        
cache_get_value_name_int(i"ClanKills"ClanInfo[i][ClanKills]);
        
cache_get_value_name_int(i"ClanDeaths"ClanInfo[i][ClanDeaths]);
        
cache_get_value_name_int(i"ClanOfficial"ClanInfo[i][ClanOfficial]);
    }
    
    
printf("[SERVER]: %d clans were loaded from the MySQL Database."rows);

Reply


Messages In This Thread
MySQL / Enumerator issue - by solstice_ - 03.04.2019, 23:24
Re: MySQL / Enumerator issue - by TheToretto - 03.04.2019, 23:48
Re: MySQL / Enumerator issue - by solstice_ - 03.04.2019, 23:51
Re: MySQL / Enumerator issue - by Logic_ - 04.04.2019, 06:20
Re: MySQL / Enumerator issue - by rockys - 04.04.2019, 13:38
Re: MySQL / Enumerator issue - by TheToretto - 04.04.2019, 13:54
Re: MySQL / Enumerator issue - by solstice_ - 04.04.2019, 19:30

Forum Jump:


Users browsing this thread: 2 Guest(s)