Small question about cache variable
#1

Hi,

I've been using the cache variable like this whenever i need to fetch the result from the db.

PHP Code:
IRCCMD:setofflevel(botidchannel[], user[], host[], params[]) {
    if(
IRC_IsOp(botidchanneluser)) {
        new 
lvl;
        if(
sscanf(params"s[24]i"paramslvl)) return IRC_GroupSay(groupIDIRC_CHANNEL"4[Error] Use: !setofflevel <username> <level>");
        if(
lvl 6) return IRC_GroupSay(groupIDIRC_CHANNEL"4[Error] Invalid level.");
        if(
isuseronline(params))
            return 
IRC_GroupSay(groupIDIRC_CHANNEL"4[Error] This user is currently online.");
          new 
Cache:result;
        
Query("SELECT `nick` FROM `users` WHERE `nick`='%e' ORDER BY `id`"params);
        
result mysql_query(mysqlquery);
        if(!
cache_get_row_count()) {
            
IRC_GroupSay(groupIDIRC_CHANNEL"4[Error] The account with this username doesn't exist.");
               
cache_delete(result);
               return 
1;
          }
        new 
tmplvl cache_get_field_content_int(0"level");
        if(
lvl == tmplvl) {
            
IRC_GroupSay(groupIDIRC_CHANNEL"4[Error] This user already has that level.");
            
cache_delete(result);
            return 
1;
        }
        if(
lvl tmplvl || lvl tmplvl)
        {
            new 
id cache_get_field_content_int(0"id"), string[100];
            
Query("UPDATE `users` SET `level`='%i' WHERE `id`='%i'"lvlid);
            
mysql_tquery(mysqlquery"QueryExecute""i"result_none);
            
format:string("3[Info] You have set %s's admin level to %i"paramslvl);
            
IRC_GroupSay(groupIDIRC_CHANNELstring);
        }
        
cache_delete(result);
    }
    return 
1;

I want to know if the way I am doing it is right or not? If someone can explain me about how to use it and how it functions, I'd be thankful.
Reply


Messages In This Thread
Small question about cache variable - by Sjn - 26.12.2015, 10:25
Re: Small question about cache variable - by Riddick94 - 26.12.2015, 12:26
Re: Small question about cache variable - by Sjn - 26.12.2015, 12:41

Forum Jump:


Users browsing this thread: 1 Guest(s)