-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathMongoDBClient-getReadPreference.txt
62 lines (41 loc) · 1.27 KB
/
MongoDBClient-getReadPreference.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
====================================
MongoDB\\Client::getReadPreference()
====================================
.. meta::
:description: Retrieve the read preference setting for a Client with the MongoDB PHP Library.
.. versionadded:: 1.2
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\Client::getReadPreference()
Returns the read preference for this client.
.. code-block:: php
function getReadPreference(): MongoDB\Driver\ReadPreference
Return Values
-------------
A :php:`MongoDB\Driver\ReadPreference <class.mongodb-driver-readpreference>`
object.
Example
-------
.. code-block:: php
<?php
$client = new MongoDB\Client('mongodb://127.0.0.1/', [
'readPreference' => 'primaryPreferred',
]);
var_dump($client->getReadPreference());
The output would then resemble:
.. code-block:: none
object(MongoDB\Driver\ReadPreference)#5 (1) {
["mode"]=>
string(16) "primaryPreferred"
}
See Also
--------
- :manual:`Read Preference </reference/read-preference>` in the MongoDB manual
- :phpmethod:`MongoDB\Collection::getReadPreference()`
- :phpmethod:`MongoDB\Database::getReadPreference()`
- :phpmethod:`MongoDB\GridFS\Bucket::getReadPreference()`