本文整理汇总了PHP中MongoClient::setWriteConcern方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoClient::setWriteConcern方法的具体用法?PHP MongoClient::setWriteConcern怎么用?PHP MongoClient::setWriteConcern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoClient
的用法示例。
在下文中一共展示了MongoClient::setWriteConcern方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setWriteConcern
/**
* Set the write concern for this connection
*
* @since 1.0.0
*
* @link http://php.net/manual/en/mongo.writeconcerns.php Write Concern
*
* @param mixed $w The write concern
* @param int $wtimeout The maximum number of milliseconds to wait for the server to satisfy the write concern. [Optional]
*
* @return \Gleez\Mango\Client
* @throws \Gleez\Mango\Exception
*/
public function setWriteConcern($w, $wtimeout = 10000)
{
if (!is_int($wtimeout)) {
throw new Exception('Param $wtimeout must be numeric value.');
}
try {
$this->config['connection']['options']['w'] = $w;
$this->config['connection']['options']['wTimeoutMS'] = (int) $wtimeout;
// PECL mongo >=1.5.0
if (version_compare(\MongoClient::VERSION, '1.5.0') >= 0) {
$this->connection->setWriteConcern($w, (int) $wtimeout);
}
} catch (Exception $e) {
throw new Exception($e->getMessage(), $e->getCode());
}
return $this;
}