| PHP » GoLang | login |
            register |
            
            about | 
| GoLang MongoCollection::findAndModify
                                request it (608)
                            GoLang replacement for PHP's MongoCollection::findAndModify
                            [edit | history] 
                             PHP MongoCollection::findAndModifyPHP original manual for MongoCollection::findAndModify [ show | php.net ]MongoCollection::findAndModify(PECL mongo >=1.3.0) MongoCollection::findAndModify — Update a document and return it Description
   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. Parameters
 Return ValuesReturns the original document, or the modified document when new is set. Errors/ExceptionsThrows MongoResultException on failure. ExamplesExample #1 MongoCollection::findAndModify() example 
<?phpThe above example will output something similar to: 
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 
<?phpThe above example will output something similar to: 
13097 : exception: Unsupported projection option: $pop
array(3) {
  ["errmsg"]=>
  string(46) "exception: Unsupported projection option: $pop"
  ["code"]=>
  int(13097)
  ["ok"]=>
  float(0)
}
See Also
 | 
                    more
                     Most requested
 
                    more
                     Last requests
 |