SunshinePHP Developer Conference 2015

The MongoUpdateBatch class

(PECL mongo >=1.5.0)

Introduction

Constructs a batch of UPDATE operations. See MongoWriteBatch.

Class synopsis

MongoUpdateBatch extends MongoWriteBatch {
/* Methods */
public __construct ( MongoCollection $collection [, array $write_options ] )
/* Inherited methods */
public bool MongoWriteBatch::add ( array $item )
final public array MongoWriteBatch::execute ( array $write_options )
}

Table of Contents

add a note add a note

User Contributed Notes 1 note

up
0
jujhar at jujhar dot com
1 month ago
Here's a stackoverflow link showing you how to use this BulkUpdate feature properly and format the updates you add to the class.

http://stackoverflow.com/questions/24753464/mongo-mass-update-to-lower-case

eg.
<?php
$batch
->add(
         array(
            
"q" => array( '_id' => $doc['_id'] ),
            
"u" => array(
                
'$set' => array(
                    
'UserName' => strtolower($doc['UserName'])
                 )
             )
         )
     );
?>
To Top