php8.5
Home/ Manual/ driver / manager/ MongoDB\Driver\Manager::getWriteConcern

MongoDB\Driver\Manager::getWriteConcern

PHP function Edit on GitHub ✎

(mongodb >=1.0.0)

Return the WriteConcern for the Manager

Description

MongoDB\Driver\Manager::getWriteConcern(): MongoDB\Driver\WriteConcern

Returns the MongoDB\Driver\WriteConcern for the Manager, which is derived from its URI options. This is the default write concern for writes and commands executed on the Manager.

Parameters Parameters

Return Values

The MongoDB\Driver\WriteConcern for the Manager.

Errors/Exceptions

Examples

MongoDB\Driver\Manager::getWriteConcern() example

php
<?php

$manager = new MongoDB\Driver\Manager('mongodb://localhost:27017');
var_dump($manager->getWriteConcern());

$manager = new MongoDB\Driver\Manager('mongodb://localhost:27017/?w=majority&wtimeoutMS=2000');
var_dump($manager->getWriteConcern());

?>

The above example will output something similar to:

output
object(MongoDB\Driver\WriteConcern)#2 (0) {
}
object(MongoDB\Driver\WriteConcern)#1 (2) {
  ["w"]=>
  string(8) "majority"
  ["wtimeout"]=>
  int(2000)
}

See Also

Source: reference/mongodb/mongodb/driver/manager/getwriteconcern.xml · from the official PHP manual (php/doc-en)