之前使用的是 PHP5, 用的 Mongo 扩展,升级到 PHP7 后,没有使用 MongoDB ,使用 jenssegers/mongodb 这个composer 包。
参考 升级PHP7操作MongoDB 这篇文章
public function update($where = [], $update = [], $upsert = false) {
$this->bulk->update($where, ['$set' => $update], ['multi' => true, 'upsert' => $upsert]);
$result = $this->mongodb->executeBulkWrite("$this->database.$this->collection", $this->bulk, $this->writeConcern);
return $result->getModifiedCount();
}
偶尔出现 MongoDB\Driver\Exception\BulkWriteException: waiting for replication timed out
PHP MongoDB BulkWriteException: waiting for replication timed out
[MongoDB\Driver\Exception\BulkWriteException]
waiting for replication timed out