MongoDB\Driver\BulkWrite
PHP Manual

MongoDB\Driver\BulkWrite::update

(mongodb >=0.2.0)

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

Beschreibung

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

Parameter-Liste

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
limit boolean Update only the first matching document (limit=1), or all matching documents (limit=0) 1
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

Rückgabewerte

Es wird kein Wert zurückgegeben.

Fehler/Exceptions

Beispiele

Beispiel #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);

?>

Siehe auch


MongoDB\Driver\BulkWrite
PHP Manual