MongoDBDatabase-getWriteConcern.txt 1.27 KB
Newer Older
1
====================================
2
MongoDB\\Database::getWriteConcern()
3
====================================
4

5 6
.. versionadded:: 1.2

7 8 9 10 11 12 13 14 15 16 17 18 19
.. default-domain:: mongodb

.. contents:: On this page
   :local:
   :backlinks: none
   :depth: 1
   :class: singlecol

Definition
----------

.. phpmethod:: MongoDB\\Database::getWriteConcern()

20
   Returns the write concern for this database.
21 22 23 24 25 26 27 28

   .. code-block:: php

      function getWriteConcern(): MongoDB\Driver\WriteConcern

Return Values
-------------

29 30
A :php:`MongoDB\\Driver\\WriteConcern <class.mongodb-driver-writeconcern>`
object.
31 32 33 34 35 36 37 38

Example
-------

.. code-block:: php

   <?php

39 40 41 42 43 44 45
   $database = (new MongoDB\Client)->selectDatabase('test', [
      'writeConcern' => new MongoDB\Driver\WriteConcern(1, 0, true),
   ]);

   var_dump($database->getWriteConcern());

The output would then resemble::
46

47 48 49 50 51 52
   object(MongoDB\Driver\WriteConcern)#5 (2) {
     ["w"]=>
     int(1)
     ["j"]=>
     bool(true)
   }
53 54 55 56

See Also
--------

57 58
- :manual:`Write Concern </reference/read-concern>` in the MongoDB manual
- :php:`MongoDB\\Driver\\WriteConcern::isDefault() <mongodb-driver-writeconcern.isdefault>`
59 60 61
- :phpmethod:`MongoDB\\Client::getWriteConcern()`
- :phpmethod:`MongoDB\\Collection::getWriteConcern()`
- :phpmethod:`MongoDB\\GridFS\\Bucket::getWriteConcern()`