MongoDB\Driver\Manager::getReadPreference

Return the ReadPreference for the Manager

&reftitle.description; final public `MongoDB\Driver\ReadPreference` `MongoDB\Driver\Manager::getReadPreference`

Returns the `MongoDB\Driver\ReadPreference` for the Manager, which is derived from its URI options. This is the default read preference for queries and commands executed on the Manager.

&reftitle.parameters; &no.function.parameters;
&reftitle.returnvalues;

The `MongoDB\Driver\ReadPreference` for the Manager.

&reftitle.errors;

&mongodb.throws.argumentparsing;

&reftitle.examples;

### `MongoDB\Driver\Manager::getReadPreference` example

    <?php

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

    $manager = new MongoDB\Driver\Manager('mongodb://localhost:27017/?readPreference=secondaryPreferred&readPreferenceTags=dc:ny,rack:1&readPreferenceTags=dc:ny&readPreferenceTags=');
    var_dump($manager->getReadPreference());

    ?>

&example.outputs.similar;

    object(MongoDB\Driver\ReadPreference)#2 (1) {
      ["mode"]=>
      string(7) "primary"
    }
    object(MongoDB\Driver\ReadPreference)#1 (2) {
      ["mode"]=>
      string(18) "secondaryPreferred"
      ["tags"]=>
      array(3) {
        [0]=>
        object(stdClass)#3 (2) {
          ["dc"]=>
          string(2) "ny"
          ["rack"]=>
          string(1) "1"
        }
        [1]=>
        object(stdClass)#4 (1) {
          ["dc"]=>
          string(2) "ny"
        }
        [2]=>
        object(stdClass)#5 (0) {
        }
      }
    }

&reftitle.seealso;

- `MongoDB\Driver\ReadPreference`
- `MongoDB\Driver\Manager::__construct`