src/Foundation/DatabaseManager.php
protected function getConnection($dbKey)
    {
        if (!isset($this->connections[$dbKey])) {
            $dbCfg = isset($this->configs['servers'][$dbKey])
                ? $this->configs['servers'][$dbKey] : [];

            if (empty($dbCfg)) {
                throw new InternalServerError(
                    T('no such db:{db} in servers', ['db' => $dbKey]));
            }

            try {
                $this->connections[$dbKey] = new Medoo([
                    'database_type' => 'mysql',
                    'database_name' => $dbCfg['name'],
                    'server' => $dbCfg['host'],
                    'username' => $dbCfg['user'],
                    'password' => $dbCfg['password'],
                    'charset' => $dbCfg['charset'],
                    'port' => $dbCfg['port'],
                    'prefix' => $dbCfg['prefix'],
                ]);
            } catch (Exception $ex) {
                //异常时，接口异常返回，并隐藏数据库帐号信息
                $errorMsg = T('can not connect to database: {db}', ['db' => $dbKey]);
                if (DI()->debug) {
                    $errorMsg = T('can not connect to database: {db}, code: {code}, cause: {msg}',
                        ['db' => $dbKey, 'code' => $ex->getCode(), 'msg' => $ex->getMessage()]);
                }
                throw new InternalServerError($errorMsg);
            }
        }

        return $this->connections[$dbKey];
    }
protected function getConnection($dbKey)
    {
        if (!isset($this->connections[$dbKey])) {
            $dbCfg = isset($this->configs['servers'][$dbKey])
                ? $this->configs['servers'][$dbKey] : [];

            if (empty($dbCfg)) {
                throw new InternalServerError(
                    T('no such db:{db} in servers', ['db' => $dbKey]));
            }

            try {
                $this->connections[$dbKey] = new Medoo([
                    'database_type' => 'mysql',
                    'database_name' => $dbCfg['name'],
                    'server' => $dbCfg['host'],
                    'username' => $dbCfg['user'],
                    'password' => $dbCfg['password'],
                    'charset' => $dbCfg['charset'],
                    'port' => $dbCfg['port'],
                    'prefix' => $dbCfg['prefix'],
                ]);
            } catch (Exception $ex) {
                //异常时，接口异常返回，并隐藏数据库帐号信息
                $errorMsg = T('can not connect to database: {db}', ['db' => $dbKey]);
                if (DI()->debug) {
                    $errorMsg = T('can not connect to database: {db}, code: {code}, cause: {msg}',
                        ['db' => $dbKey, 'code' => $ex->getCode(), 'msg' => $ex->getMessage()]);
                }
                throw new InternalServerError($errorMsg);
            }
        }

        return $this->connections[$dbKey];
    }
创建数据库连接，如果需要采用其他数据库，可重载此函数

@param string $dbKey 数据库表名唯一KEY
@throws InternalServerError
@return Medoo