PHP MongoDB updates multiple documents using $ in / $ or

It's hard for me to figure out how to build an update request in PHP that will update document identifiers X, Y, and Z. Does anyone have any experience with this?

$ids[] = array( new MongoId('4eaaf929498fe2c80300000c'), new MongoId('4eaaff24498fe2ba0900001f') ); $collection->update( array('_id' => array('$in' => $ids)), array('$set' => array("title"=>"test")), array("upsert" => true) ); 
+4
source share
1 answer

I guess your problem is that only one document is being updated, right? If so, there is another parameter that you must specify in the third parameter (parameter) for the update method:

 multiple => true 

Otherwise, it will only update the first match of your request. See the documentation for the update method at:

http://de.php.net/manual/en/mongocollection.update.php

+9
source

All Articles