1.连接MongoDB数据库(在已安装php-mongodb扩展的前提下)

$config = "mongodb://{$user}:{$pass}@{$host}:{$port}";
$mongodb = new \MongoDB\Driver\Manager($config );

2.简单统计

$command = new \MongoDB\Driver\Command(['count' => $collection,'query'=>$filter]);
$result = $mongodb->executeCommand($db,$command);

junziyouzhong
2 声望1 粉丝