diff --git a/reference/mongo/exceptions.xml b/reference/mongo/exceptions.xml index 545d33f27a..51aceb6e2a 100644 --- a/reference/mongo/exceptions.xml +++ b/reference/mongo/exceptions.xml @@ -37,5 +37,9 @@ $ sudo update-rc.d umountnfs.sh stop 15 0 6 . &reference.mongo.mongocursortimeoutexception; &reference.mongo.mongoconnectionexception; &reference.mongo.mongogridfsexception; + &reference.mongo.mongoduplicatekeyexception; + &reference.mongo.mongoprotocolexception; + &reference.mongo.mongoexecutiontimeoutexception; + &reference.mongo.mongowriteconcernexception; diff --git a/reference/mongo/mongoduplicatekeyexception.xml b/reference/mongo/mongoduplicatekeyexception.xml new file mode 100644 index 0000000000..5d742f2e84 --- /dev/null +++ b/reference/mongo/mongoduplicatekeyexception.xml @@ -0,0 +1,103 @@ + + + + + + The MongoDuplicateKeyException class + MongoDuplicateKeyException + + + + +
+ &reftitle.intro; + + Thrown when attempting to insert a document into a collection which already contains the same values for the unique keys. + +
+ + +
+ &reftitle.classsynopsis; + + + + MongoDuplicateKeyException + + + + + MongoDuplicateKeyException + + + + extends + MongoWriteConcernException + + + + &InheritedProperties; + + + + &InheritedMethods; + + + + + +
+ +
+ &reftitle.examples; + + Catching MongoDuplicateKeyException + +selectCollection("test", "test"); + +$c->insert(array('_id' => 1)); +try { + $c->insert(array('_id' => 1)); +} catch (MongoWriteConcernException $e) { + echo $e->getMessage(), "\n"; +} +?> +]]> + + &examples.outputs.similar; + + + + +
+ +
+ +
+ + diff --git a/reference/mongo/mongoexecutiontimeoutexception.xml b/reference/mongo/mongoexecutiontimeoutexception.xml new file mode 100644 index 0000000000..efb86baecf --- /dev/null +++ b/reference/mongo/mongoexecutiontimeoutexception.xml @@ -0,0 +1,73 @@ + + + + + + The MongoExecutionTimeoutException class + MongoExecutionTimeoutException + + + + +
+ &reftitle.intro; + + Throw when a operation times out server side (e.g. in MongoDB). + + + To configure the operation timeout threshold, use MongoCursor::maxTimeMS + +
+ + +
+ &reftitle.classsynopsis; + + + + MongoExecutionTimeoutException + + + + + MongoExecutionTimeoutException + + + + extends + MongoException + + + + &InheritedProperties; + + + + + +
+ +
+ +
+ + diff --git a/reference/mongo/mongoprotocolexception.xml b/reference/mongo/mongoprotocolexception.xml new file mode 100644 index 0000000000..b08e84c253 --- /dev/null +++ b/reference/mongo/mongoprotocolexception.xml @@ -0,0 +1,106 @@ + + + + + + The MongoProtocolException class + MongoProtocolException + + + + +
+ &reftitle.intro; + + When talking to MongoDB 2.6.0, and later, certain operations (such as writes) may throw MongoProtocolException when the response + from the server did not make sense - for example during network failure (we could read the entire response) or data corruption. + + + This exception is also thrown when attempting to talk newer protocols then the server supports, for example using the + MongoWriteBatch when talking to a MongoDB server prior to 2.6.0. + +
+ + +
+ &reftitle.classsynopsis; + + + + MongoProtocolException + + + + + MongoProtocolException + + + + extends + MongoException + + + + &InheritedProperties; + + + + + +
+ +
+ &reftitle.examples; + + Catching MongoProtocolException + + Running the following example against MongoDB prior to 2.6.0 will throw an MongoProtocolException + + +selectCollection("test", "test"); + +try { + $batch = new MongoInsertBatch($c); +} catch(MongoProtocolException $e) { + echo $e->getMessage(); +} +?> +]]> + + &examples.outputs.similar; + + + + +
+ + +
+ +
+ + diff --git a/reference/mongo/mongoresultexception.xml b/reference/mongo/mongoresultexception.xml index 63c2ca11ee..21ba7acd87 100644 --- a/reference/mongo/mongoresultexception.xml +++ b/reference/mongo/mongoresultexception.xml @@ -51,11 +51,6 @@ &Methods; - - diff --git a/reference/mongo/mongoresultexception/getdocument.xml b/reference/mongo/mongoresultexception/getdocument.xml index 1198483a94..55f80710bf 100644 --- a/reference/mongo/mongoresultexception/getdocument.xml +++ b/reference/mongo/mongoresultexception/getdocument.xml @@ -32,6 +32,84 @@ + + &reftitle.examples; + + <methodname>MongoResultException::getDocument</methodname> example + +selectCollection("test", "test"); + +$c->insert(array( + "name" => "Next promo", + "inprogress" => false, + "priority" => 0, + "tasks" => array( "select product", "add inventory", "do placement"), +) ); + +$c->insert(array( + "name" => "Biz report", + "inprogress" => false, + "priority" => 1, + "tasks" => array( "run sales report", "email report" ) +) ); + +$c->insert(array( + "name" => "Biz report", + "inprogress" => false, + "priority" => 2, + "tasks" => array( "run marketing report", "email report" ) + ), + array("w" => true) +); + +try { + $retval = $c->findAndModify( + array("inprogress" => false, "name" => "Biz report"), + array('$set' => array('$set' => array('inprogress' => true, "started" => new MongoDate()))), + null, + array( + "sort" => array("priority" => -1), + "new" => true, + ) + ); +} catch(MongoResultException $e) { + echo $e->getMessage(), "\n"; + $res = $e->getDocument(); + var_dump($res); +} +?> +]]> + + &examples.outputs.similar; + + + array(5) { + ["connectionId"]=> + int(6) + ["err"]=> + string(30) "$set is not valid for storage." + ["code"]=> + int(52) + ["n"]=> + int(0) + ["ok"]=> + float(1) + } + ["ok"]=> + float(0) + ["errmsg"]=> + string(30) "$set is not valid for storage." +} +]]> + + + + + + + The MongoWriteConcernException class + MongoWriteConcernException + + + + +
+ &reftitle.intro; + + MongoWriteConcernException is thrown when a write fails. See for how to set failure thresholds. + + + Prior to MongoDB 2.6.0 GLE would determin when a write failed. + +
+ + +
+ &reftitle.classsynopsis; + + + + MongoWriteConcernException + + + + + MongoWriteConcernException + + + + extends + MongoCursorException + + + + &InheritedProperties; + + + + &Methods; + + + &InheritedMethods; + + + + + +
+ +
+ + &reference.mongo.entities.mongowriteconcernexception; + +
+ + diff --git a/reference/mongo/mongowriteconcernexception/getdocument.xml b/reference/mongo/mongowriteconcernexception/getdocument.xml new file mode 100644 index 0000000000..dac57cbccf --- /dev/null +++ b/reference/mongo/mongowriteconcernexception/getdocument.xml @@ -0,0 +1,56 @@ + + + + + + MongoWriteConcernException::getDocument + Get the error document + + + + &reftitle.description; + + public arrayMongoWriteConcernException::getDocument + + + + Returns the actual response from the server that was interperated as an error. + + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + A MongoDB document, if available, as an array. + + + + + + +