static function check_init() { if (!count(SDB::get_tables_list())) { $sql = file_get_contents(BASE . 'conf/simple.' . conf('db.type') . '.sql'); if (conf('db.type') == 'mysql') { $spl = explode(';', $sql); foreach ($spl as $part) { $cmd = new SDBCommand($part); $cmd->execute(); } } else { $cmd = new SDBCommand($sql); $cmd->execute(); } SDB::reset_cached_data(); $fl = new FileItem(); $fl->parent_id = 0; $fl->name = 's'; $fl->type = FileItem::Folder; $fl->save(); Initiator::fill_db(S_BASE, $fl->id); } }
protected function _init_table() { if (strlen($this->_db_table)) { return; } $classname = strtolower(get_class($this)); $tables = SDB::get_tables_list(); $sclsname = substr($classname, 0, -1); if (in_array($classname, $tables)) { $this->map_table($classname); } elseif (in_array($classname . 's', $tables)) { $this->map_table($classname . 's'); } elseif (in_array($sclsname . 'ies', $tables)) { $this->map_table($sclsname . 'ies'); } elseif (!$this->_fuzzy_find_table($classname, $sclsname, $tables)) { throw new Exception("Tables '{$classname}' ('{$classname}s', '{$sclsname}ies') doesn't exists. Use map_table to set table manually."); } }
<?php if (!count(SDB::get_tables_list())) { $sql = file_get_contents(BASE . '../common/examples.' . conf('db.type') . '.sql'); if (conf('db.type') == 'mysql') { $spl = explode(';', $sql); foreach ($spl as $part) { $cmd = new SDBCommand($part); $cmd->execute(); } } else { $cmd = new SDBCommand($sql); $cmd->execute(); } SDB::reset_cached_data(); }