MongoDB\Driver\WriteResult::getWriteConcernError
(mongodb >=1.0.0)
MongoDB\Driver\WriteResult::getWriteConcernError — 발생한 쓰기 문제 오류를 반환합니다.
설명
final public MongoDB\Driver\WriteResult::getWriteConcernError(): ?MongoDB\Driver\WriteConcernError
매개변수
이 함수에는 매개변수가 없습니다.
반환 값
쓰기 작업 중에 쓰기 관련 오류가 발생하면 MongoDB\Driver\WriteConcernError를 반환하고 그렇지 않으면 null
을 반환합니다.
오류/예외
- 인수 구문 분석 오류에 대해 MongoDB\Driver\Exception\InvalidArgumentException을 던집니다.
Examples
예제 #1 MongoDB\Driver\WriteResult::getWriteConcernError() 예제
<?php
$manager = new MongoDB\Driver\Manager("mongodb://rs1.example.com,rs2.example.com/?replicaSet=myReplicaSet");
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$writeConcern = new MongoDB\Driver\WriteConcern(2, 1);
try {
$manager->executeBulkWrite('db.collection', $bulk, $writeConcern);
} catch(MongoDB\Driver\Exception\BulkWriteException $e) {
var_dump($e->getWriteResult()->getWriteConcernError());
}
?>
위의 예는 다음과 유사한 결과를 출력합니다.
object(MongoDB\Driver\WriteConcernError)#6 (3) { ["message"]=> string(33) "waiting for replication timed out" ["code"]=> int(64) ["info"]=> object(stdClass)#7 (1) { ["wtimeout"]=> bool(true) } }