<?php
$m = new MongoClient();
$test = $m->selectDb('test');
$coll = $test->selectCollection('my_table');
// without $set, the whole document will be replaced
$success = $coll->update(
array('_id' => new MongoId('5421399f895f69524d8b4567')),
array('$set' => array('value' => 'nothing'))
);
dump($success);
/*
resulting changes with $set
array(4) {
["_id"]=>
object(MongoId)#8 (1) {
["id"]=>
string(24) "5421399f895f69524d8b4567"
}
["name"]=>
string(17) "myname"
["object"]=>
array(0) {
}
["value"]=>
string(7) "nothing"
}
*/
^ array:5 [
"updatedExisting" => true
"n" => 1
"connectionId" => 21
"err" => null
"ok" => 1.0
]