(PECL mongo >=1.5.0)
Examples:
MongoWriteBatch example

Adding documents to a Insert batch and then execute it

<?php
$mc = new MongoClient("localhost");

$collection = $mc->selectCollection("test", "test");


$docs = array();
$docs[] = array("my" => "demo");
$docs[] = array("is" => "working");
$docs[] = array("pretty" => "well");

$batch = new MongoInsertBatch($collection);
foreach($docs as $document) {
    $batch->add($document);
}
$retval = $batch->execute(array("w" => 1));
var_dump($retval);
?>

The above example will output:

array(2) {
  ["nInserted"]=>
  int(3)
  ["ok"]=>
  bool(true)
}
MongoWriteBatch::__construct

(PECL mongo >= 1.5.0) Creates a new batch of write operations

2016-02-24 16:20:55
MongoWriteBatch::add

(PECL mongo >= 1.5.0) Adds a write operation to a batch

2016-02-24 16:20:55
MongoWriteBatch::execute

(PECL mongo >= 1.5.0) Executes a batch of write operations

2016-02-24 16:20:55