function query_keke_witkey_district($is_cache = 0, $cache_time = 0)
 {
     if ($this->_where) {
         $sql = "select * from {$this->_tablename} where " . $this->_where;
     } else {
         $sql = "select * from {$this->_tablename}";
     }
     if ($is_cache) {
         $this->_cache_config['is_cache'] = $is_cache;
     }
     if ($cache_time) {
         $this->_cache_config['time'] = $cache_time;
     }
     if ($this->_cache_config['is_cache']) {
         if (CACHE_TYPE) {
             $keke_cache = new keke_cache_class(CACHE_TYPE);
             $id = $this->_tablename . ($this->_where ? "_" . substr(md5($this->_where), 0, 6) : '');
             $data = $keke_cache->get($id);
             if ($data) {
                 return $data;
             } else {
                 $res = $this->_dbop->query($sql);
                 $keke_cache->set($id, $res, $this->_cache_config['time']);
                 $this->_where = "";
                 return $res;
             }
         }
     } else {
         $this->_where = "";
         return $this->_dbop->query($sql);
     }
 }
Example #2
0
 private static function db_cache($is_get, $sql, $ttl, $result = 'QUERY_EMPTY')
 {
     global $_K;
     $cache_obj = new keke_cache_class(CACHE_TYPE, $_K['cache_config']);
     $key = $cache_obj->generate_id($sql);
     if ($is_get == 1) {
         $res = $cache_obj->get($key);
     } else {
         $res = $cache_obj->set($key, $result, $ttl);
     }
     return $res;
 }