1。连接MongoDB数据库(前提是已经安装了php-mongodb扩展)$config="mongodb://{$user}:{$pass}@{$host}:{$port}";$mongodb=新的\MongoDB\Driver\Manager($config);2.简单统计$command=new\MongoDB\Driver\Command(['count'=>$collection,'query'=>$filter]);$result=$mongodb->e??xecuteCommand($db,$command);
