Think/Db/Driver/Mongo.php
public function connect($config = '', $linkNum = 0)
    {
        if (!isset($this->linkID[$linkNum])) {
            if (empty($config)) {
                $config = $this->config;
            }
            $host = 'mongodb://'.($config['username'] ? "{$config['username']}" : '').($config['password'] ? ":{$config['password']}@" : '').$config['hostname'].($config['hostport'] ? ":{$config['hostport']}" : '').'/'.($config['database'] ? "{$config['database']}" : '');
            try {
                $this->linkID[$linkNum] = new \MongoClient($host, $this->config['params']);
            } catch (\MongoConnectionException $e) {
                E($e->getmessage());
            }
        }

        return $this->linkID[$linkNum];
    }
public function connect($config = '', $linkNum = 0)
    {
        if (!isset($this->linkID[$linkNum])) {
            if (empty($config)) {
                $config = $this->config;
            }
            $host = 'mongodb://'.($config['username'] ? "{$config['username']}" : '').($config['password'] ? ":{$config['password']}@" : '').$config['hostname'].($config['hostport'] ? ":{$config['hostport']}" : '').'/'.($config['database'] ? "{$config['database']}" : '');
            try {
                $this->linkID[$linkNum] = new \MongoClient($host, $this->config['params']);
            } catch (\MongoConnectionException $e) {
                E($e->getmessage());
            }
        }

        return $this->linkID[$linkNum];
    }
连接数据库方法
@param string $config
@param int $linkNum
@return mixed|\PDO