MongoDB\Driver\BulkWriteCommandResult::getInsertedCount

(mongodb >=2.1.0)

MongoDB\Driver\BulkWriteCommandResult::getInsertedCountReturns the number of documents inserted

Опис

final public MongoDB\Driver\BulkWriteCommandResult::getInsertedCount(): int

Параметри

У цієї функції немає параметрів.

Значення, що повертаються

Returns the total number of documents inserted (excluding upserts) by all operations.

Помилки/виключення

Приклади

Приклад #1 MongoDB\Driver\BulkWriteCommandResult::getInsertedCount() example

<?php

$manager
= new MongoDB\Driver\Manager;

$bulk = new MongoDB\Driver\BulkWriteCommand;
$bulk->insertOne('db.coll', ['x' => 1]);
$bulk->updateOne('db.coll', ['x' => 1], ['$set' => ['y' => 3]]);
$bulk->updateOne('db.coll', ['x' => 2], ['$set' => ['y' => 1]], ['upsert' => true]);
$bulk->updateOne('db.coll', ['x' => 3], ['$set' => ['y' => 2]], ['upsert' => true]);
$bulk->deleteMany('db.coll', []);

$result = $manager->executeBulkWriteCommand($bulk);

var_dump($result->getInsertedCount());

?>

Поданий вище приклад виведе:

int(1)

Прогляньте також

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top