Read all database settings

This commit is contained in:
2021-01-27 12:46:19 +03:00
parent 23cb69919c
commit 1683da7cf3

View File

@@ -58,11 +58,21 @@ class HRCCommand extends Command
file_put_contents($result_file, json_encode($result));
}
private function getCoreConfig($name)
{
$config = parse_ini_file(mb_strtolower(file_get_contents(CORE_PATH . '/../../db.ini')));
return $config[$name];
}
public function initDB()
{
$code = $this->option('unn');
DB::disconnect('mysql');
Config::set('database.connections.mysql.username', $this->getCoreConfig('user'));
Config::set('database.connections.mysql.password', $this->getCoreConfig('password'));
Config::set('database.connections.mysql.host', $this->getCoreConfig('server'));
Config::set('database.connections.mysql.port', $this->getCoreConfig('port'));
Config::set('database.connections.mysql.database', $code);
DB::reconnect();
}