|
MongoCollection::findAndModifyUpdate a document and return it Beschreibung
public array MongoCollection::findAndModify
( array
$query
[, array $update
[, array $fields
[, array $options
]]] )The findAndModify command atomically modifies and returns a single document. By default, the returned document does not include the modifications made on the update. To return the document with the modifications made on the update, use the new option. Parameter-Liste
RückgabewerteReturns the original document, or the modified document when new is set. Fehler/ExceptionsThrows MongoResultException on failure. BeispieleBeispiel #1 MongoCollection::findAndModify example
<?phpDas oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:
array(6) {
["_id"]=>
object(MongoId)#7 (1) {
["$id"]=>
string(24) "5091b5b244415e8cc3000002"
}
["inprogress"]=>
bool(true)
["name"]=>
string(10) "Biz report"
["priority"]=>
int(2)
["started"]=>
object(MongoDate)#8 (2) {
["sec"]=>
int(1351726514)
["usec"]=>
int(925000)
}
["tasks"]=>
array(2) {
[0]=>
string(20) "run marketing report"
[1]=>
string(12) "email report"
}
}
Beispiel #2 MongoCollection::findAndModify error handling
<?phpDas oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:
13097 : exception: Unsupported projection option: $pop
array(3) {
["errmsg"]=>
string(46) "exception: Unsupported projection option: $pop"
["code"]=>
int(13097)
["ok"]=>
float(0)
}
Siehe auch
|