Think/Model.php
public function connect($linkNum = 0, array $config = [])
    {
        $this->_db[$linkNum] = Db::getInstance($config);
        // 切换数据库连接
        $this->db = $this->_db[$linkNum];
        $this->_after_db();
        // 字段检测
        if (!empty($this->name) && $this->autoCheckFields) {
            $this->_checkTableInfo();
        }

        return $this;
    }
public function connect($linkNum = 0, array $config = [])
    {
        $this->_db[$linkNum] = Db::getInstance($config);
        // 切换数据库连接
        $this->db = $this->_db[$linkNum];
        $this->_after_db();
        // 字段检测
        if (!empty($this->name) && $this->autoCheckFields) {
            $this->_checkTableInfo();
        }

        return $this;
    }
切换当前的数据库连接
@param mixed $linkNum 连接序号
@param array $config 数据库连接信息

@return $this
@throws BaseException