Docs Menu
Docs Home
/ / /
PHP Library Manual
/ /

MongoDB\Client::getReadPreference()

On this page

  • Definition
  • Return Values
  • Example
  • See Also

New in version 1.2.

MongoDB\Client::getReadPreference()

Returns the read preference for this client.

function getReadPreference(): MongoDB\Driver\ReadPreference

A MongoDB\Driver\ReadPreference object.

<?php
$client = new MongoDB\Client('mongodb://127.0.0.1/', [
'readPreference' => 'primaryPreferred',
]);
var_dump($client->getReadPreference());

The output would then resemble:

object(MongoDB\Driver\ReadPreference)#5 (1) {
["mode"]=>
string(16) "primaryPreferred"
}
  • Read Preference in the MongoDB manual

  • MongoDB\Collection::getReadPreference()

  • MongoDB\Database::getReadPreference()

  • MongoDB\GridFS\Bucket::getReadPreference()

Back

getReadConcern()