mirror of
https://github.com/macintoshplus/mongo-php-driver.git
synced 2026-04-02 06:12:08 +02:00
27 lines
573 B
PHP
27 lines
573 B
PHP
<?php
|
|
|
|
$ordered = true;
|
|
|
|
$insertBatch = new \MongoDB\Batch\InsertBatch($ordered);
|
|
$insertBatch
|
|
->add($hannes)
|
|
->add($hayley);
|
|
|
|
$w = 'majority';
|
|
$w = 500;
|
|
|
|
$writeConcern = new \MongoDB\WriteConcern($w, $wtimeout);
|
|
|
|
$mm = new \MongoDB\Manager("mongodb://server1,server2/?replicaSet=FOOBAR");
|
|
|
|
$result = $mm->executeWrite("db.collection", $insertBatch, $writeConcern);
|
|
|
|
assert($result instanceof \MongoDB\WriteResult);
|
|
|
|
printf(
|
|
"Inserted %d documents %s in %d msec\n",
|
|
$result->getOpCount(),
|
|
$result->getServer()->getHostname(),
|
|
$result->getTimer()
|
|
);
|