March 2019
Intermediate to advanced
394 pages
11h 4m
English
The new PHP driver supports the BulkWrite interface to minimize network calls to MongoDB:
$manager = new MongoDB\Driver\Manager('mongodb://localhost:27017');$bulk = new MongoDB\Driver\BulkWrite(array("ordered" => true));$bulk->insert(array( "isbn" => "401", "name" => "MongoDB and PHP" ));$bulk->insert(array( "isbn" => "402", "name" => "MongoDB and PHP, 2nd Edition" ));$bulk->update(array("isbn" => "402"), array('$set' => array("price" => 15)));$bulk->insert(array( "isbn" => "403", "name" => "MongoDB and PHP, revisited" ));$result = $manager->executeBulkWrite('mongo_book.books', $bulk);print_r($result);
The result can be seen as follows:
MongoDB\Driver\WriteResult Object( [nInserted] => 3 [nMatched] => 1 [nModified] => 1 [nRemoved] ...
Read now
Unlock full access