International PHP Conference Munich 2025

MongoDB\Driver\Exception\BulkWriteCommandException::getWriteConcernErrors

(mongodb >=2.1.0)

MongoDB\Driver\Exception\BulkWriteCommandException::getWriteConcernErrorsRenvoie les erreurs de préoccupation d'écriture

Description

final public MongoDB\Driver\Exception\BulkWriteCommandException::getWriteConcernErrors(): array

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Un tableau de chacun des MongoDB\Driver\WriteConcernErrors qui se sont produite lors de l'exécution de l'écriture en masse. Cette liste peut avoir plusieurs entrés si plus d'une commande de serveur était nécessaire pour exécuter l'écriture en masse.

Exemples

Exemple #1 Exemple de MongoDB\Driver\Exception\BulkWriteCommandException::getWriteConcernErrors()

<?php

$manager
= new MongoDB\Driver\Manager;

$bulk = new MongoDB\Driver\BulkWriteCommand;
$bulk->insertOne('db.coll', ['x' => 1]);

$writeConcern = new MongoDB\Driver\WriteConcern(50);

try {
$result = $manager->executeBulkWriteCommand($bulk, ['writeConcern' => $writeConcern]);
} catch (
MongoDB\Driver\Exception\BulkWriteCommandException $e) {
var_dump($e->getWriteConcernErrors());
}

?>

Résultat de l'exemple ci-dessus est similaire à :

array(1) {
  [0]=>
  object(MongoDB\Driver\WriteConcernError)#6 (3) {
    ["message"]=>
    string(29) "Not enough data-bearing nodes"
    ["code"]=>
    int(100)
    ["info"]=>
    object(stdClass)#8 (1) {
      ["writeConcern"]=>
      object(stdClass)#7 (3) {
        ["w"]=>
        int(50)
        ["wtimeout"]=>
        int(0)
        ["provenance"]=>
        string(14) "clientSupplied"
      }
    }
  }
}

Voir aussi

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top