public function createTableIfNotExists() { if (SQL::tableExists($this->table_name, false)) { return false; } $sql = $this->getCreateTableStatement(); q($sql); return true; }
/** * @return bool table exists */ private function ensureDbTableExists() { $table = $this->getDbTableName(); // May be empty if ($table == 'm_s') { return true; } $schema = new TableStructure(); $schema->setTableName($this->getDbTableName()); $schema->setTableStructure($this->getTableStructure()); if (!SQL::tableExists($table)) { // Create table; $schema->createTableIfNotExists(); } // Update structure using auto-created migrations // $schema->ensureDbTableStructureIsFresh(); // This changes a lot of required items, do not use in future return true; }
/** * Init all settings * @param bool $no_cache fetch data from cache or not * @return array */ public function init($no_cache = false) { $this->bootCacher(); // From local cache if (self::$_cached_settings && is_array(self::$_cached_settings) && !$no_cache) { return self::$_cached_settings; } if ($no_cache) { // Force cache invalidation self::$_cached_settings = []; } else { // Get from cache self::$_cached_settings = Cacher::getInstance()->getDefaultCacher()->get(self::CACHE_KEY); } if (!self::$_cached_settings && SQL::tableExists('cms_settings')) { // Get from DB $settings_collection = new SettingEntityRepository(); self::$_cached_settings = $settings_collection->getPairs('value', 'name'); Cacher::getInstance()->getDefaultCacher()->set(self::CACHE_KEY, self::$_cached_settings); } if (!is_array(self::$_cached_settings)) { self::$_cached_settings = []; } return self::$_cached_settings; }