j_install_db 초기화 코드 정리
This commit is contained in:
+23
-16
@@ -63,6 +63,8 @@ $db->addHook('run_failed', function(){
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$mysqli_obj = $db->get();
|
||||||
|
|
||||||
$prefix = basename(__DIR__);
|
$prefix = basename(__DIR__);
|
||||||
|
|
||||||
$result = Util::generateFileUsingSimpleTemplate(
|
$result = Util::generateFileUsingSimpleTemplate(
|
||||||
@@ -84,24 +86,29 @@ if($result !== true){
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!class_exists('\\sammo\\DB')) {
|
//최소한의 테이블 처리를 위해 수동으로 초기화하도록 하자
|
||||||
$loader = require __DIR__.'/../vendor/autoload.php';
|
if($mysqli_obj->multi_query(file_get_contents(__DIR__.'/sql/reset.sql'))){
|
||||||
$loader->addClassMap((function () {
|
while(true){
|
||||||
$d_settingMap = [];
|
if (!$mysqli_obj->more_results()) {
|
||||||
foreach (glob(__DIR__.'/d_setting/*.orig.php') as $filepath) {
|
break;
|
||||||
$filepath = str_replace('.orig.php', '.php', $filepath);
|
}
|
||||||
if(!file_exists($filepath)) {
|
if(!$mysqli_obj->next_result()){
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
$filename = basename($filepath);
|
}
|
||||||
$classname = explode('.', $filename)[0];
|
|
||||||
$d_settingMap['sammo\\'.$classname] = $filepath;
|
|
||||||
};
|
|
||||||
return $d_settingMap;
|
|
||||||
})());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResetHelper::clearDB($db, $prefix);
|
if($mysqli_obj->multi_query(file_get_contents(__DIR__.'/sql/schema.sql'))){
|
||||||
|
while(true){
|
||||||
|
if (!$mysqli_obj->more_results()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(!$mysqli_obj->next_result()){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ServConfig::getServerList()[$prefix]->closeServer();
|
ServConfig::getServerList()[$prefix]->closeServer();
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class ResetHelper{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function clearDB(?\MeekroDB $db = null, ?string $prefix = null):array{
|
static public function clearDB():array{
|
||||||
$servRoot = realpath(__DIR__.'/../');
|
$servRoot = realpath(__DIR__.'/../');
|
||||||
|
|
||||||
if(!file_exists($servRoot.'/logs') || !file_exists($servRoot.'/data')){
|
if(!file_exists($servRoot.'/logs') || !file_exists($servRoot.'/data')){
|
||||||
@@ -72,15 +72,11 @@ class ResetHelper{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($prefix === null){
|
$prefix = DB::prefix();
|
||||||
$prefix = DB::prefix();
|
|
||||||
}
|
|
||||||
|
|
||||||
ServConfig::getServerList()[$prefix]->closeServer();
|
ServConfig::getServerList()[$prefix]->closeServer();
|
||||||
|
|
||||||
if($db === null){
|
$db = DB::db();
|
||||||
$db = DB::db();
|
|
||||||
}
|
|
||||||
$mysqli_obj = $db->get();
|
$mysqli_obj = $db->get();
|
||||||
|
|
||||||
$serverID = $prefix.'_'.date("ymd").'_'.Util::randomStr(4);
|
$serverID = $prefix.'_'.date("ymd").'_'.Util::randomStr(4);
|
||||||
|
|||||||
Reference in New Issue
Block a user