src/DB/DBFactory.php
private static function getDsn($params, $type = 'mysql', $use_unix_socket = true)
    {
        if (!empty($params['dsn'])) {
            return $params['dsn'];
        }

        if (!isset($params['host']) || !isset($params['name'])) {
            throw new CoreException('连接数据库所需参数不足');
        }

        if ($use_unix_socket && !empty($params['unix_socket'])) {
            $dsn = "{$type}:unix_socket={$params['unix_socket']};dbname={$params['name']};";
        } else {
            $dsn = "{$type}:host={$params['host']};dbname={$params['name']};";
            if (isset($params['port'])) {
                $dsn .= "port={$params['port']};";
            }

            if (isset($params['charset'])) {
                $dsn .= "charset={$params['charset']};";
            }
        }

        return $dsn;
    }
private static function getDsn($params, $type = 'mysql', $use_unix_socket = true)
    {
        if (!empty($params['dsn'])) {
            return $params['dsn'];
        }

        if (!isset($params['host']) || !isset($params['name'])) {
            throw new CoreException('连接数据库所需参数不足');
        }

        if ($use_unix_socket && !empty($params['unix_socket'])) {
            $dsn = "{$type}:unix_socket={$params['unix_socket']};dbname={$params['name']};";
        } else {
            $dsn = "{$type}:host={$params['host']};dbname={$params['name']};";
            if (isset($params['port'])) {
                $dsn .= "port={$params['port']};";
            }

            if (isset($params['charset'])) {
                $dsn .= "charset={$params['charset']};";
            }
        }

        return $dsn;
    }
生成DSN

@param array $params
@param string $type
@param bool|true $use_unix_socket
@return string
@throws CoreException