Пример #1
0
 /**
  * Get whether secondary read queries are allowed for this collection.
  *
  * This method wraps getSlaveOkay() for driver versions before 1.3.0. For
  * newer drivers, this method considers any read preference other than
  * PRIMARY as a true "slaveOkay" value.
  */
 public function getSlaveOkay()
 {
     if (version_compare(phpversion('mongo'), '1.3.0', '<')) {
         return $this->getMongoCollection()->getSlaveOkay();
     }
     $readPref = $this->getMongoCollection()->getReadPreference();
     if (is_numeric($readPref['type'])) {
         $readPref['type'] = ReadPreference::convertNumericType($readPref['type']);
     }
     return \MongoClient::RP_PRIMARY !== $readPref['type'];
 }
Пример #2
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testConvertNumericTypeShouldThrowExceptionForInvalidType()
 {
     ReadPreference::convertNumericType(-1);
 }