MongoCursor::slaveOkay PHP Method

slaveOkay() public method

Sets whether this query can be done on a slave This method will override the static class variable slaveOkay.
public slaveOkay ( boolean $okay = true ) : MongoCursor
$okay boolean If it is okay to query the slave.
return MongoCursor Returns this cursor
    public function slaveOkay($okay = true)
    {
        $this->errorIfOpened();
        $this->setReadPreferenceFromSlaveOkay($okay);
        return $this;
    }

Usage Example

Beispiel #1
0
 public function getCollection($collectionName)
 {
     MongoCursor::$slaveOkay = true;
     //if empty($this->dbName) throw error;
     $dbName = $this->dbName;
     Yii::import('application.extensions.mp.db.mongodb.*');
     $this->_collection = new MongoMSCollection($this->_writeServer->{$dbName}, $collectionName);
     $this->_collection->addSlaves($this->_readServers);
     return $this->_collection;
 }
All Usage Examples Of MongoCursor::slaveOkay