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