public function loadConfig($config = null): void
    {
        $baseClass = Base::getInstance();
        $this->errorLevel = (string)$baseClass->Database->MySQL->errorLevel;

        if (\is_null($config)) {
            $config = $baseClass->Database->MySQL->defaultConnection;
        }
        if (!($config instanceof AbstractConfig)) {
            throw new RuntimeException('$config must be an instance of MS\LightFramework\Config\AbstractConfig');
        }

        $this->databaseHost = (string)$config->databaseHost;
        $this->databaseUser = (string)$config->databaseUser;
        $this->databasePass = (string)$config->databasePass;
        $this->databaseName = (string)$config->databaseName;
        $this->connectionCharset = (string)$config->connectionCharset;
        $this->connectionCollation = (string)$config->connectionCollation;

        $this->openConnection();
        $this->selectDatabase($this->databaseName);
        $this->setConnectionCharset($this->connectionCharset);
        $this->setConnectionCollation($this->connectionCollation);
    }