setWriteConcern() public method

public setWriteConcern ( $wstring, $wtimeout )
 /**
  * Connects to our database
  */
 public function connect()
 {
     if (!extension_loaded('mongo')) {
         throw new EMongoException(yii::t('yii', 'We could not find the MongoDB extension ( http://php.net/manual/en/mongo.installation.php ), please install it'));
     }
     try {
         $this->_mongo = new MongoClient($this->connectionString, $this->connectOptions);
         $dbname = $this->db;
         $this->_db = $this->_mongo->{$dbname};
         $this->_db->setWriteConcern($this->options['writeConcerns'], $this->options['wTimeoutMS']);
     } catch (Exception $e) {
         throw new EMongoException(yii::t('yii', 'We could not find the MongoDB extension ( http://php.net/manual/en/mongo.installation.php ), please install it'));
     }
 }
Beispiel #2
0
 /**
  * Define write concern.
  * May be used only if mongo extension version >=1.5
  *
  * @param string|integer $w write concern
  * @param int $timeout timeout in milliseconds
  * @return \Sokil\Mongo\Database
  * @throws \Sokil\Mongo\Exception
  */
 public function setWriteConcern($w, $timeout = 10000)
 {
     if (!$this->mongoDB->setWriteConcern($w, (int) $timeout)) {
         throw new Exception('Error setting write concern');
     }
     return $this;
 }