|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
| 2 | +<!-- EN-Revision: 4639881688d3faaf0073ad71fe0a4b730aea15a0 Maintainer: Fan2Shrek Status: ready --> |
| 3 | +<!-- Reviewed: yes --> |
| 4 | + |
| 5 | +<refentry xml:id="mongodb-driver-bulkwriteexception.getwriteresult" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> |
| 6 | + <refnamediv> |
| 7 | + <refname>MongoDB\Driver\Exception\BulkWriteException::getWriteResult</refname> |
| 8 | + <refpurpose>Renvoie le WriteResult pour l'opération d'écriture échouée</refpurpose> |
| 9 | + </refnamediv> |
| 10 | + |
| 11 | + <refsect1 role="description"> |
| 12 | + &reftitle.description; |
| 13 | + <methodsynopsis> |
| 14 | + <modifier>final</modifier> <modifier>public</modifier> <type>MongoDB\Driver\WriteResult</type><methodname>MongoDB\Driver\Exception\BulkWriteException::getWriteResult</methodname> |
| 15 | + <void /> |
| 16 | + </methodsynopsis> |
| 17 | + <para> |
| 18 | + Renvoie le <classname>MongoDB\Driver\WriteResult</classname> pour l'opération |
| 19 | + d'écriture échouée. Les méthodes |
| 20 | + <function>MongoDB\Driver\WriteResult::getWriteErrors</function> et |
| 21 | + <function>MongoDB\Driver\WriteResult::getWriteConcernError</function> |
| 22 | + peuvent être utilisées pour obtenir des détails supplémentaires sur l'erreur. |
| 23 | + </para> |
| 24 | + |
| 25 | + </refsect1> |
| 26 | + |
| 27 | + <refsect1 role="parameters"> |
| 28 | + &reftitle.parameters; |
| 29 | + &no.function.parameters; |
| 30 | + </refsect1> |
| 31 | + |
| 32 | + <refsect1 role="returnvalues"> |
| 33 | + &reftitle.returnvalues; |
| 34 | + <para> |
| 35 | + Le <classname>MongoDB\Driver\WriteResult</classname> pour l'opération |
| 36 | + d'écriture échouée. |
| 37 | + </para> |
| 38 | + </refsect1> |
| 39 | + |
| 40 | + |
| 41 | + <refsect1 role="examples"> |
| 42 | + &reftitle.examples; |
| 43 | + <example> |
| 44 | + <title>Exemple de <function>MongoDB\Driver\Exception\BulkWriteException::getWriteResult</function></title> |
| 45 | + <programlisting role="php"> |
| 46 | +<![CDATA[ |
| 47 | +<?php |
| 48 | +
|
| 49 | +$manager = new MongoDB\Driver\Manager('mongodb://localhost'); |
| 50 | +$bulk = new MongoDB\Driver\BulkWrite; |
| 51 | +$bulk->insert(['_id' => 1]); |
| 52 | +$bulk->insert(['_id' => 1]); |
| 53 | +
|
| 54 | +try { |
| 55 | + $manager->executeBulkWrite('db.collection', $bulk); |
| 56 | +} catch (MongoDB\Driver\Exception\BulkWriteException $e) { |
| 57 | + $writeResult = $e->getWriteResult(); |
| 58 | +
|
| 59 | + if ($writeConcernError = $writeResult->getWriteConcernError()) { |
| 60 | + var_dump($writeConcernError); |
| 61 | + } |
| 62 | +
|
| 63 | + if ($writeErrors = $writeResult->getWriteErrors()) { |
| 64 | + var_dump($writeErrors); |
| 65 | + } |
| 66 | +} |
| 67 | +
|
| 68 | +?> |
| 69 | +]]> |
| 70 | + </programlisting> |
| 71 | + &example.outputs.similar; |
| 72 | + <screen> |
| 73 | +<![CDATA[ |
| 74 | +array(1) { |
| 75 | + [0]=> |
| 76 | + object(MongoDB\Driver\WriteError)#5 (4) { |
| 77 | + ["message"]=> |
| 78 | + string(70) "E11000 duplicate key error index: db.collection.$_id_ dup key: { : 1 }" |
| 79 | + ["code"]=> |
| 80 | + int(11000) |
| 81 | + ["index"]=> |
| 82 | + int(1) |
| 83 | + ["info"]=> |
| 84 | + NULL |
| 85 | + } |
| 86 | +} |
| 87 | +]]> |
| 88 | + </screen> |
| 89 | + </example> |
| 90 | + </refsect1> |
| 91 | + |
| 92 | + |
| 93 | + <refsect1 role="seealso"> |
| 94 | + &reftitle.seealso; |
| 95 | + <simplelist> |
| 96 | + <member><classname>MongoDB\Driver\WriteResult</classname></member> |
| 97 | + <member><function>MongoDB\Driver\Manager::executeBulkWrite</function></member> |
| 98 | + </simplelist> |
| 99 | + </refsect1> |
| 100 | + |
| 101 | +</refentry> |
| 102 | + |
| 103 | +<!-- Keep this comment at the end of the file |
| 104 | +Local variables: |
| 105 | +mode: sgml |
| 106 | +sgml-omittag:t |
| 107 | +sgml-shorttag:t |
| 108 | +sgml-minimize-attributes:nil |
| 109 | +sgml-always-quote-attributes:t |
| 110 | +sgml-indent-step:1 |
| 111 | +sgml-indent-data:t |
| 112 | +indent-tabs-mode:nil |
| 113 | +sgml-parent-document:nil |
| 114 | +sgml-default-dtd-file:"~/.phpdoc/manual.ced" |
| 115 | +sgml-exposed-tags:nil |
| 116 | +sgml-local-catalogs:nil |
| 117 | +sgml-local-ecat-files:nil |
| 118 | +End: |
| 119 | +vim600: syn=xml fen fdm=syntax fdl=2 si |
| 120 | +vim: et tw=78 syn=sgml |
| 121 | +vi: ts=1 sw=1 |
| 122 | +--> |
0 commit comments