MongoCollection::setReadPreference

Set the read preference for this collection

&reftitle.description; public `bool` `MongoCollection::setReadPreference` `string` `read_preference` `array` `tags`
&reftitle.parameters; &mongo.setreadpreference.parameters;
&reftitle.returnvalues; &mongo.setreadpreference.returnvalues;
&reftitle.errors; &mongo.setreadpreference.errors;
&reftitle.examples;

### `MongoCollection::setReadPreference` tag set array syntax example

    <?php

    $m = new MongoClient();
    $c = $m->test->users;

    // Prefer the nearest server in the "east" data center also used for reporting,
    // but fall back to a server in the "west" data center
    $c->setReadPreference(MongoClient::RP_NEAREST, array(
        array('dc' => 'east', 'use' => 'reporting'),
        array('dc' => 'west'),
    ));
    ?>

&reftitle.seealso;

- The read preferences documentation.