Example #1
0
 public function __construct($type)
 {
     $this->type = $type;
     $this->fields = Arrays::exists($type, Data::$_fields) ? Data::$_fields[$type] : Data::noConfigFields($type);
     $this->settings = Arrays::exists($type, Data::$_settings) ? Data::$_settings[$type] : Data::defaultConfig($type);
     $this->session = session(Inflector::camelize('store_' . $type));
     $data = $this->session->getData();
     if (empty($data)) {
         $data = array();
         $this->session->setData($data);
     }
     $dbFile = STORAGE_PATH . DS . Inflector::camelize('store_' . $type) . '.store';
     $this->db = new SQLite3($dbFile);
     $q = "SELECT * FROM sqlite_master WHERE type = 'table' AND name = 'datas'";
     $res = $this->db->query($q);
     if (false === $res->fetchArray()) {
         $this->db->exec('CREATE TABLE datas (id VARCHAR PRIMARY KEY, datecreate, datemodify, value)');
     }
 }
Example #2
0
File: Sql.php Project: schpill/thin
 public function __construct($type, $entity = 'db')
 {
     $this->type = $type;
     $this->entity = $entity;
     $this->fields = Arrays::exists($type, Data::$_fields) ? Data::$_fields[$type] : Data::noConfigFields($type);
     $this->settings = Arrays::exists($type, Data::$_settings) ? Data::$_settings[$type] : Data::defaultConfig($type);
     $this->session = session(Inflector::camelize('storeSQL_' . $type));
     $data = $this->session->getData();
     if (empty($data)) {
         $data = array();
         $this->session->setData($data);
     }
     $this->db = $this->connect();
     if (false === $this->checkTable()) {
         $q = 'CREATE TABLE IF NOT EXISTS `datas_' . $this->type . '` (
               `id` varchar(9) NOT NULL,
               `datecreate` int(11) unsigned NOT NULL,
               `datemodify` int(11) unsigned NOT NULL,
               `value` longtext NOT NULL
             ) ENGINE=MyISAM DEFAULT CHARSET=utf8;';
         $this->_query($q);
     }
 }