(PECL mongo >=0.9.0)
MongoCollection::update — Update records based on a given criteria
$criteria
   , array $new_object
   [, array $options = array()
  ] )
criteria
     Query criteria for the documents to update.
new_object
     The object used to update the matched documents. This may either contain update operators (for modifying specific fields) or be a replacement document.
options
     An array of options for the update operation. Currently available options include:
"upsert"
          If no document matches $criteria, a new
          document will be inserted.
         
          If a new document would be inserted and
          $new_object contains atomic modifiers
          (i.e. $ operators), those operations will be
          applied to the $criteria parameter to create
          the new document. If $new_object does not
          contain atomic modifiers, it will be used as-is for the inserted
          document. See the upsert examples below for more information.
         
"multiple"
All documents matching $criteria will be updated. MongoCollection::update() has exactly the opposite behavior of MongoCollection::remove(): it updates one document by default, not all matching documents. It is recommended that you always specify whether you want to update multiple documents or a single document, as the database may change its default behavior at some point in the future.
"fsync"
Булево, по умолчанию FALSE. Если включено журналирование, то работает также как и "j". Если журналирование не включено, то операции записи блокируются пока не будут синхронизированы с файлами на жестком диске. Если TRUE, то применяется подтвержденная вставка и эта опция переопределяет опцию "w" в значение 0.
Замечание: Если журналирование включено, то пользователю настоятельно рекомендуется использовать опцию "j" вместо "fsync". Не используйте "fsync" и "j" одновременно,так как это может привести к ошибке.
"j"
Булево, по умолчанию FALSE. Блокирует операции записи пока они не будут синхронизированы с журналом на диске. Если TRUE, то применяется подтвержденная вставка  и эта опция переопределяет опцию "w" в значение 0.
Замечание: Если применяется эта опция и журналирование отключено, то MongoDB 2.6+ выбросит ошибку и прервет запись; старые версии сервера просто игнорируют эту опцию.
"socketTimeoutMS"
Эта опция определяет время в миллисекундах для общения в socket. Если сервер не ответил за отведенное время, то будет брошено исключение MongoCursorTimeoutException, и не будет никакой возможности определить произвел ли сервер запись или нет. Значение -1 используется для постоянно отключения этой функции. Значением по умолчанию для MongoClient является 30000 (30 секунд).
"w"
Смотрите Контроль записи. Значение по умолчанию для MongoClient является 1.
"wTimeoutMS"
Эта опция определяет лимит времени в миллисекундах для подтверждения контроля записи. Она применима только, если "w" больше 1, так как ограничение времени относится к репликации. Если контроль записи не подтвержден за отведенное время, то будет выброшено исключение MongoCursorException. Значение 0 для постоянного отключения. Значением по умолчанию для MongoClient является 10000 (десять секунд).
The following options are deprecated and should no longer be used:
"safe"
Устаревшая опция. Используйте опцию "w" контроля записи.
"timeout"
Устаревший псевдоним для "socketTimeoutMS".
"wtimeout"
Устаревший псевдоним для "wTimeoutMS".
   Returns an array containing the status of the update if the
   "w" option is set. Otherwise, returns TRUE.
  
Fields in the status array are described in the documentation for MongoCollection::insert().
Исключение MongoCursorException бросается, если установлена опция "w" и не прошла запись.
Исключение MongoCursorTimeoutException бросается, если опция "w" установлена в значение больше одного и операция заняла больше, чем MongoCursor::$timeout миллисекунд. При этом операция на сервере не прерывается, так как это ограничение времени работает на клиентской стороне. Операция в миллисекундах в MongoCollection::$wtimeout.
| Версия | Описание | 
|---|---|
| 1.5.0 | 
         Added the "wTimeoutMS" option, which replaces
         "wtimeout". Emits  
         Added the "socketTimeoutMS" option, which replaces
         "timeout". Emits  
         Emits  | 
| 1.3.4 | Added "wtimeout" option. | 
| 1.3.0 | Added "w" option. 
         The  | 
| 1.2.11 | Emits E_DEPRECATEDwhenoptionsis scalar. | 
| 1.2.0 | Added "timeout" option. | 
| 1.0.11 | Disconnects on "not master" errors if "safe" is set. | 
| 1.0.9 | Added ability to pass integers to the "safe" option, which previously only accepted booleans. Added "fsync" option. The return type was changed to be an array containing error information if the "safe" option is used. Otherwise, a boolean is returned as before. | 
| 1.0.5 | Added "safe" option. | 
| 1.0.1 | Changed optionsparameter from boolean to array.
        Pre-1.0.1, the second parameter was an optional boolean value specifying
        an upsert. | 
Пример #1 MongoCollection::update()
Adding an address field to a document.
<?php
$c->insert(array("firstname" => "Bob", "lastname" => "Jones" ));
$newdata = array('$set' => array("address" => "1 Smith Lane"));
$c->update(array("firstname" => "Bob"), $newdata);
var_dump($c->findOne(array("firstname" => "Bob")));
?>
Результатом выполнения данного примера будет что-то подобное:
array(4) {
  ["_id"]=>
  object(MongoId)#6 (0) {
  }
  ["firstname"]=>
  string(3) "Bob"
  ["lastname"]=>
  string(5) "Jones"
  ["address"]=>
  string(12) "1 Smith Lane"
}
Пример #2 MongoCollection::update() upsert examples
    Upserts can simplify code, as a single line can create the document if it
    does not exist (based on $criteria), or update an
    existing document if it matches.
   
    In the following example, $new_object contains an
    atomic modifier. Since the collection is empty and upsert must insert a new
    document, it will apply those operations to the
    $criteria parameter in order to create the document.
   
<?php
$c->drop();
$c->update(
    array("uri" => "/summer_pics"),
    array('$inc' => array("page hits" => 1)),
    array("upsert" => true)
);
var_dump($c->findOne());
?>
Результатом выполнения данного примера будет что-то подобное:
array(3) {
  ["_id"]=>
  object(MongoId)#9 (0) {
  }
  ["uri"]=>
  string(12) "/summer_pics"
  ["page hits"]=>
  int(1)
}
    If $new_object does not contain atomic modifiers
    (i.e. $ operators), upsert will use
    $new_object as-is for the new document. This matches
    the behavior of a normal update, where not using atomic modifiers causes the
    document to be overwritten.
   
<?php
$c->drop();
$c->update(
    array("name" => "joe"),
    array("username" => "joe312", "createdAt" => new MongoDate()), 
    array("upsert" => true)
);
var_dump($c->findOne());
?>
Результатом выполнения данного примера будет что-то подобное:
array(3) {
  ["_id"]=>
  object(MongoId)#10 (0) {
  }
  ["username"]=>
  string(6) "joe312"
  ["createdAt"]=>
  object(MongoDate)#4 (0) {
  }
}
Пример #3 MongoCollection::update() multiple example
    By default, MongoCollection::update() will only update
    the first document matching $criteria that it
    finds. Using the "multiple" option can override this behavior, if needed.
   
This example adds a "gift" field to every person whose birthday is in the next day.
<?php
$today = array('$gt' => new MongoDate(), '$lt' => new MongoDate(strtotime("+1 day")));
$people->update(
    array("birthday" => $today),
    array('$set' => array('gift' => $surprise)),
    array("multiple" => true)
);
?>
The PHP documentation on updates and the » MongoDB core docs.