MongoDB\Driver\BulkWrite
PHP Manual

MongoDB\Driver\BulkWrite::update

(mongodb >=0.2.0)

MongoDB\Driver\BulkWrite::updateAdd an update operation to the bulk

说明

public void MongoDB\Driver\BulkWrite::update ( array|object $filter , array|object $newObj [, array $updateOptions ] )

参数

filter

The search filter.

newObj

Either an array of update operators, or the full object to be replaced with

updateOptions

updateOptions
Option Type Description Default
multi boolean Update only the first matching document (multi=false), or all matching documents (multi=true) false
upsert boolean If filter does not match an existing document, insert the newObj as a new object, applying any atomic modifiers to the filter if applicable. 0

返回值

没有返回值。

错误/异常

范例

Example #1 MongoDB\Driver\BulkWrite::update() example

<?php

$bulk 
= new MongoDB\Driver\BulkWrite(true);
$bulk->update(array("tag" => "mongodb"), array("multi" => false));
$bulk->update(array(  "x" => "2"     ), array("y" => 3'$set' => array("z" => 4)), array("upsert" => 0));

$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
$writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY1000);
$result $manager->executeBulkWrite("databaseName.collectionName"$bulk$writeConcern);

?>

参见


MongoDB\Driver\BulkWrite
PHP Manual