lib/Doctrine/MongoDB/Collection.php
public function setSlaveOkay($ok = true)
    {
        $prevSlaveOkay = $this->getSlaveOkay();

        if ($ok) {
            // Preserve existing tags for non-primary read preferences
            $readPref = $this->getReadPreference();
            $tags = ! empty($readPref['tagsets']) ? $readPref['tagsets'] : [];
            $this->mongoCollection->setReadPreference(\MongoClient::RP_SECONDARY_PREFERRED, $tags);
        } else {
            $this->mongoCollection->setReadPreference(\MongoClient::RP_PRIMARY);
        }

        return $prevSlaveOkay;
    }
public function setSlaveOkay($ok = true)
    {
        $prevSlaveOkay = $this->getSlaveOkay();

        if ($ok) {
            // Preserve existing tags for non-primary read preferences
            $readPref = $this->getReadPreference();
            $tags = ! empty($readPref['tagsets']) ? $readPref['tagsets'] : [];
            $this->mongoCollection->setReadPreference(\MongoClient::RP_SECONDARY_PREFERRED, $tags);
        } else {
            $this->mongoCollection->setReadPreference(\MongoClient::RP_PRIMARY);
        }

        return $prevSlaveOkay;
    }
public function setSlaveOkay ( $ ok = true ) { $ prevSlaveOkay = $ this -> getSlaveOkay ( ) ; if ( $ ok ) { // Preserve existing tags for non-primary read preferences $ readPref = $ this -> getReadPreference ( ) ; $ tags = ! empty ( $ readPref [ 'tagsets' ] ) ? $ readPref [ 'tagsets' ] : [ ] ; $ this -> mongoCollection -> setReadPreference ( \ MongoClient :: RP_SECONDARY_PREFERRED , $ tags ) ; } else { $ this -> mongoCollection -> setReadPreference ( \ MongoClient :: RP_PRIMARY ) ; } return $ prevSlaveOkay ; }
Set whether secondary read queries are allowed for this collection.

This method wraps setSlaveOkay() for driver versions before 1.3.0. For
newer drivers, this method wraps setReadPreference() and specifies
SECONDARY_PREFERRED.

@see http://php.net/manual/en/mongocollection.setreadpreference.php
@see http://php.net/manual/en/mongocollection.setslaveokay.php
@param boolean $ok
@return boolean Previous slaveOk value
Set whether secondary read queries are allowed for this collection .