<?php


namespace app\api\model;


use MongoDB\Client;
use MongoDB\Driver\BulkWrite;
use MongoDB\Driver\Manager;
use think\Model;

class Mongodb extends Model
{

    //连接mongodb数据库
    public static function Client($db2,$table){
        $client = new Client();
        /*$db2=$client->db2;//数据库
        $db=$db2->db1;//自定义数据表集合*/
        $db=$client->selectDatabase($db2);
        return $db->selectCollection($table);
    }


    //连接mongodb数据库
    public static function Manager($url="mongodb://127.0.0.1/"){
        return new Manager($url);
    }
}