« MongoDB\Driver\BulkWriteCommandResult::getInsertResults
MongoDB\Driver\BulkWriteCommandResult::getModifiedCount »

MongoDB\Driver\BulkWriteCommandResult::getMatchedCount

(mongodb >=2.1.0)

MongoDB\Driver\BulkWriteCommandResult::getMatchedCount — Returns the number of documents selected for update

説明

final public function MongoDB\Driver\BulkWriteCommandResult::getMatchedCount(): int

If the update operation results in no change to the document (e.g. setting the value of a field to its current value), the matched count may be greater than the value returned by MongoDB\Driver\BulkWriteCommandResult::getModifiedCount().

パラメータ

この関数にはパラメータはありません。

戻り値

Returns the total number of documents selected for update by all operations.

エラー / 例外

例

例1 MongoDB\Driver\BulkWriteCommandResult::getMatchedCount() 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->getMatchedCount());

?>

上の例の出力は以下となります。

int(1)

参考

関連キーワード:
MongoDB   Driver   BulkWriteCommandResult   bulk   number   documents   update   getMatchedCount   coll   selected   getModifiedCount   updateOne   results   Throws   Exception   write   acknowledged   manager   upsert   getInsertResults   mongodb   final   operation   change   document
関連する関数・ページ:
mongodb-driver-bulkwritecommandresult.getmodifiedcount   mongodb-driver-bulkwritecommandresult.getinsertedcount   mongodb-driver-bulkwritecommandresult.getdeletedcount   mongodb-driver-bulkwritecommandresult.getupsertedcount   mongodb-driver-bulkwritecommandresult.getdeleteresults   mongodb-driver-bulkwritecommandresult.getupdateresults