예제 #1
0
 /**
  * Construct a table in memory.
  *
  * @param object $resultSet Pass n result set from PDO query.
  *
  * @since 1.0
  */
 public function __construct($dbh, $qry, $params = null, $fetch = DB::FETCH_BOTH)
 {
     parent::__construct();
     $this->fetch = $fetch;
     if (is_object($dbh)) {
         $this->table = $dbh->fetchAll($fetch);
     } else {
         $cacheKey = $dbh . ' ' . $qry . ' ' . serialize($params);
         if (($cacheValue = self::$dataCache->get($cacheKey)) !== false) {
             $this->table = $cacheValue;
         } else {
             if (($resultSet = DB::query($dbh, $qry, $params)) === false) {
                 return;
             }
             $this->table = $resultSet->fetchAll($fetch);
             self::$dataCache->set($cacheKey, $this->table);
         }
     }
 }
예제 #2
0
 public function xls($tName = '')
 {
     if (($tableName = Request::get('tblName', $tName)) == '') {
         exit;
     }
     XLS::output(DB::query(DB::DEF, 'SELECT * FROM ' . $tableName), $tableName);
 }