//获取一个数据库中所有集合的文档总数
$ this-> database-> command(array('dbStats'=> 1));
PHP:
$command = new \MongoDB\Driver\Command(array("dbStats" => 1));
$count = $manager->executeCommand($config['db'] ,$command)->toArray()[0]->count;
//获取一个数据库中某一个集合的文档总数
$ this-> database-> command(array('collStats'=> 'test'));
PHP:
$command = new \MongoDB\Driver\Command(array("collStats" => 'test')); $count = $manager->executeCommand($config['db'] ,$command)->toArray()[0]->count;