php man page for mongoduplicatekeyexception

Query: mongoduplicatekeyexception

OS: php

Section: 3

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

MONGODUPLICATEKEYEXCEPTION(3)						 1					     MONGODUPLICATEKEYEXCEPTION(3)

The MongoDuplicateKeyException class

INTRODUCTION
Thrown when attempting to insert a document into a collection which already contains the same values for the unique keys.
CLASS SYNOPSIS
MongoDuplicateKeyException MongoDuplicateKeyExceptionextends MongoWriteConcernException Inherited properties o protected string$message o protected int$code o protected string$file o protected int$line Inherited methods o public array MongoWriteConcernException::getDocument (void )
EXAMPLES
Example #1 Catching MongoDuplicateKeyException <?php $mc = new MongoClient("localhost"); $c = $mc->selectCollection("test", "test"); $c->insert(array('_id' => 1)); try { $c->insert(array('_id' => 1)); } catch (MongoWriteConcernException $e) { echo $e->getMessage(), " "; } ?> The above examples will output something similar to: localhost:27017: insertDocument :: caused by :: 11000 E11000 duplicate key error index: test.test.$_id_ dup key: { : 1 } PHP Documentation Group MONGODUPLICATEKEYEXCEPTION(3)
Related Man Pages
mongo(3) - php
mongodbdriverbulkwrite(3) - php
solrqueryresponse(3) - php
mongocollection.find(3) - php
mongogridfs.storebytes(3) - php
Similar Topics in the Unix Linux Community
Simple rules of the UNIX.COM forums:
Status of UNIX.COM Forum Transformation
Please Welcome Ravinder Singh to the Moderation Team
The Order of the Wizard's Hat - Lifetime Achievement Award 2019 - Congrats to Don Cragun
The Order of the Wizard's Hat - Lifetime Achievement Award 2019 - Congrats to Wolf Machowitsch