CakeFest 2024: The Official CakePHP Conference

MongoDB\Driver\WriteResult::isAcknowledged

(mongodb >=1.0.0)

MongoDB\Driver\WriteResult::isAcknowledgedRetourne si l'écriture a été reconnue

Description

final public MongoDB\Driver\WriteResult::isAcknowledged(): bool

Si l'écriture a été reconnue, d'autres champs de comptage seront disponible pour l'objet MongoDB\Driver\WriteResult.

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Retourne true si l'écriture a été reconnue, et false sinon.

Erreurs / Exceptions

  • Lance une exception MongoDB\Driver\InvalidArgumentException lors d'une erreur survenue pendant l'analyse d'un argument.

Exemples

Exemple #1 MongoDB\Driver\WriteResult::isAcknowledged() avec la préocupation d'écriture reconnue

<?php

$manager
= new MongoDB\Driver\Manager;

$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);

$result = $manager->executeBulkWrite('db.collection', $bulk);

var_dump($result->isAcknowledged());

?>

L'exemple ci-dessus va afficher :

bool(true)

Exemple #2 MongoDB\Driver\WriteResult::isAcknowledged() avec la préocupation d'écriture non reconnue

<?php

$manager
= new MongoDB\Driver\Manager;

$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);

$result = $manager->executeBulkWrite('db.collection', $bulk, new MongoDB\Driver\WriteConcern(0));

var_dump($result->isAcknowledged());

?>

L'exemple ci-dessus va afficher :

bool(false)
add a note

User Contributed Notes

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