(mongodb >=0.2.0)
MongoDB\Driver\BulkWrite::update — Add an update operation to the bulk
$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
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::MAJORITY, 1000);
$result = $manager->executeBulkWrite("databaseName.collectionName", $bulk, $writeConcern);
?>