Esempio n. 1
0
 /**
  * Check table infomation
  */
 private function _checkTableInfo()
 {
     if (empty($this->fields)) {
         $fieldsCache = KantFactory::getConfig()->get('db_fields_cache');
         if ($fieldsCache) {
             $this->fields = Cache::get($this->fieldsCacheName);
             return;
         }
         $this->flushTableInfo();
     }
 }
Esempio n. 2
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;
 }