Пример #1
0
 /**
  * Get cache object
  */
 public static function getCache()
 {
     if (!self::$container['cache']) {
         $config = self::getConfig()->get('cache.default');
         self::$container['cache'] = Cache::getInstance($config);
     }
     return self::$container['cache'];
 }
Пример #2
0
 /**
  * Init
  */
 private function _init()
 {
     $this->_initConfig();
     $this->_initSession();
     Cache::platform();
 }
Пример #3
0
 /**
  * Flush table infomation and cache
  */
 public function flushTableInfo()
 {
     $fields = $this->db->getFields($this->table);
     if (!$fields) {
         return false;
     }
     $this->fields = array_keys($fields);
     foreach ($fields as $key => $val) {
         $type[$key] = $val['type'];
         $this->fields['_type'] = $type;
     }
     $fieldsCache = KantFactory::getConfig()->get('db_fields_cache');
     if ($fieldsCache) {
         Cache::set($this->fieldsCacheName, $this->fields);
     }
 }
Пример #4
0
 /**
  *
  *  SQl query
  *
  * @param string $sql
  * @param string $method
  * @return array
  */
 public function query($sql, $fetchMode = PDO::FETCH_ASSOC)
 {
     $rows = null;
     if ($this->ttl) {
         $this->clearFields();
         $rows = Cache::get($sql);
         if (!empty($rows)) {
             return $rows;
         }
     }
     if (!is_resource($this->dbh)) {
         $this->connect();
     }
     $sth = $this->dbh->prepare($sql);
     $sth->execute();
     $rows = $sth->fetchAll($fetchMode);
     if ($this->ttl) {
         Cache::set($sql, $rows, $this->ttl);
     } else {
         Cache::delete($sql);
     }
     return $rows;
     $this->sqls[] = $sql;
     $this->queryCount++;
     $this->clearFields();
     return $rows;
 }