php-doc-en/reference/mongo/mongoduplicatekeyexception.xml
Hannes Magnusson 36c5526571 Document new exceptions
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@332960 c90b9560-bf6c-de11-be94-00142212c4b1
2014-03-11 21:45:16 +00:00

103 lines
3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.mongoduplicatekeyexception" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The MongoDuplicateKeyException class</title>
<titleabbrev>MongoDuplicateKeyException</titleabbrev>
<partintro>
<!-- {{{ MongoDuplicateKeyException intro -->
<section xml:id="mongoduplicatekeyexception.intro">
&reftitle.intro;
<para>
Thrown when attempting to insert a document into a collection which already contains the same values for the <link linkend="mongocollection.ensureindex">unique keys</link>.
</para>
</section>
<!-- }}} -->
<section xml:id="mongoduplicatekeyexception.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>MongoDuplicateKeyException</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>MongoDuplicateKeyException</classname>
</ooclass>
<ooclass>
<modifier>extends</modifier>
<classname>MongoWriteConcernException</classname>
</ooclass>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">&InheritedProperties;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('exception.synopsis')/descendant::db:fieldsynopsis)" />
<classsynopsisinfo role="comment">&InheritedMethods;</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.mongowriteconcernexception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not(@role='procedural')])" />
</classsynopsis>
<!-- }}} -->
</section>
<section xml:id="mongoduplicatekeyexception.examples">
&reftitle.examples;
<example xml:id="mongoduplicatekeyexception.example.catch">
<title>Catching MongoDuplicateKeyException</title>
<programlisting role="php">
<![CDATA[
<?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(), "\n";
}
?>
]]>
</programlisting>
&examples.outputs.similar;
<screen>
<![CDATA[
localhost:27017: insertDocument :: caused by :: 11000 E11000 duplicate key error index: test.test.$_id_ dup key: { : 1 }
]]>
</screen>
</example>
</section>
</partintro>
</phpdoc:classref>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->