@@ -45,44 +45,24 @@ in your replica sets.
45
45
Configure Read and Write Operations
46
46
-----------------------------------
47
47
48
- You can control how the library routes read operations by setting a **read preference**.
49
- You can also control options for how the library waits for acknowledgment of
50
- read and write operations on a replica set by setting a **read concern** and a
51
- **write concern**.
48
+ You can control how the library routes read operations by setting a read preference.
49
+ You can also control how the library waits for acknowledgment of read and write operations
50
+ on a replica set by setting a read and write concern.
52
51
53
52
This section shows how to configure the read preference, read concern, and write
54
53
concern at various levels by passing an options array parameter to the following
55
54
methods:
56
55
57
- - :ref:`MongoDB\\Client::__construct() <php-read-write-client>`: Configures read
58
- and write settings at the client level
59
- - :ref:`MongoDB\\Client::startSession() <php-read-write-session>`: Configures read
60
- and write settings at the session level
61
- - :ref:`MongoDB\\Driver\\Session::startTransaction() <php-read-write-transaction>`:
62
- Configures read and write settings at the transaction level
63
- - :ref:`MongoDB\\Client::selectDatabase() <php-read-write-database>`: Configures read
64
- and write settings at the database level
65
- - :ref:`MongoDB\\Client::selectCollection() <php-read-write-collection>`: Configures read
66
- and write settings at the collection level
67
-
68
- In the options parameter, specify the following values:
69
-
70
- - ``readPreference``: Sets the read preference. For a list of available read
71
- preferences, see :php:`MongoDB\Driver\ReadPreference <mongodb-driver-readpreference>`
72
- in the extension API documentation.
73
- - ``readConcern``: Sets the read concern. For a list of available read
74
- concerns, see :php:`MongoDB\Driver\ReadConcern <mongodb-driver-readconcern>`
75
- in the extension API documentation.
76
- - ``writeConcern``: Sets the write concern. For a list of available write
77
- concerns, see :php:`MongoDB\Driver\WriteConcern <mongodb-driver-writeconcern>`
78
- in the extension API documentation.
79
-
80
- .. note::
81
-
82
- When setting a write concern at the ``MongoDB\Client`` level, specify the ``w``
83
- value in an options array rather than ``writeConcern.`` You can also specify
84
- read and write settings in the connection URI. For more information,
85
- see the :ref:`php-read-write-client`.
56
+ - :ref:`MongoDB\Client::__construct() <php-read-write-client>`: Configures client-level
57
+ settings
58
+ - :ref:`MongoDB\Client::startSession() <php-read-write-session>`: Configures session-level
59
+ settings
60
+ - :ref:`MongoDB\Driver\Session::startTransaction() <php-read-write-transaction>`:
61
+ Configures transaction-level settings
62
+ - :ref:`MongoDB\Client::selectDatabase() <php-read-write-database>`: Configures
63
+ database-level settings
64
+ - :ref:`MongoDB\Client::selectCollection() <php-read-write-collection>`: Configures read
65
+ collection-level settings
86
66
87
67
.. _php-read-write-client:
88
68
@@ -179,7 +159,7 @@ array to the ``selectDatabase()`` method. The code configures the following sett
179
159
- ``MAJORITY`` write concern: The majority of all replica set members
180
160
must acknowledge the write operation
181
161
182
- .. literalinclude:: /includes/databases-collections/databases-collections .php
162
+ .. literalinclude:: /includes/read-write-pref .php
183
163
:language: php
184
164
:dedent:
185
165
:start-after: start-database-settings
@@ -201,7 +181,7 @@ array to the ``selectCollection()`` method. The code configures the following se
201
181
set members
202
182
- ``0`` write concern: Requests no acknowledgment of the write operation
203
183
204
- .. literalinclude:: /includes/databases-collections/databases-collections .php
184
+ .. literalinclude:: /includes/read-write-pref .php
205
185
:language: php
206
186
:dedent:
207
187
:start-after: start-collection-settings
@@ -299,6 +279,6 @@ guide, see the following API documentation:
299
279
300
280
- :phpmethod:`MongoDB\Client::__construct()`
301
281
- :phpmethod:`MongoDB\Client::startSession()`
302
- - :php:`MongoDB\Driver\Session::startTransaction() `
282
+ - :php:`MongoDB\Driver\Session::startTransaction`
303
283
- :phpmethod:`MongoDB\Client::selectDatabase()`
304
284
- :phpmethod:`MongoDB\Client::selectCollection()`
0 commit comments