本文整理汇总了PHP中MongoDB::setWriteConcern方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoDB::setWriteConcern方法的具体用法?PHP MongoDB::setWriteConcern怎么用?PHP MongoDB::setWriteConcern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoDB
的用法示例。
在下文中一共展示了MongoDB::setWriteConcern方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect
/**
* 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'));
}
}
示例2: setWriteConcern
/**
* 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;
}