Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

bulk write mongodb php

<?php

$bulk = new MongoDBDriverBulkWrite;

$document1 = ['title' => 'one'];
$document2 = ['_id' => 'custom ID', 'title' => 'two'];
$document3 = ['_id' => new MongoDBBSONObjectId, 'title' => 'three'];

$_id1 = $bulk->insert($document1);
$_id2 = $bulk->insert($document2);
$_id3 = $bulk->insert($document3);

var_dump($_id1, $_id2, $_id3);

$manager = new MongoDBDriverManager('mongodb://localhost:27017');
$result = $manager->executeBulkWrite('db.collection', $bulk);

?>
Source by www.php.net #
 
PREVIOUS NEXT
Tagged: #bulk #write #mongodb #php
ADD COMMENT
Topic
Name
6+3 =