/** * 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; }