update : 2015.11.03
php.shukuma.com검색:
|
MongoCollection::findAndModify(PECL mongo >=1.3.0) MongoCollection::findAndModify — Update a document and return it 설명
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. 인수
반환값Returns the original document, or the modified document when new is set. 오류/예외Throws MongoResultException on failure. 예제Example #1 MongoCollection::findAndModify() example
<?php 위 예제의 출력 예시: 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" } } Example #2 MongoCollection::findAndModify() error handling
<?php 위 예제의 출력 예시: 13097 : exception: Unsupported projection option: $pop array(3) { ["errmsg"]=> string(46) "exception: Unsupported projection option: $pop" ["code"]=> int(13097) ["ok"]=> float(0) } 참고
|