// \$dbCollection 为简写,连接数据库
$maxIds = $dbCollection->find(
[],
[
'sort' => [
'_id' => -1
],
'skip' => 0,
'limit' => 1,
]
);
foreach ($maxIds as $value) {
$maxId = $value['_id'];
}
// 报错
// PHP Fatal error: Uncaught MongoDB\Driver\Exception\RuntimeException: Another cursor derived from this client is in exhaust.
查看mongodb扩展发现版本过低,升级扩展版本即可。
root@84cc684f5-c2kd7:/www/script# php --ri mongodb
mongodb
mongodb support => enabled
mongodb version => 1.1.5
mongodb stability => stable
libmongoc version => 1.3.3
libbson version => 1.3.3