See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]
1 <?php 2 /* 3 * Copyright 2015-present MongoDB, Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * https://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 namespace MongoDB; 19 20 use MongoDB\Driver\WriteResult; 21 use MongoDB\Exception\BadMethodCallException; 22 23 /** 24 * Result class for a delete operation. 25 */ 26 class DeleteResult 27 { 28 /** @var WriteResult */ 29 private $writeResult; 30 31 /** @var boolean */ 32 private $isAcknowledged; 33 34 public function __construct(WriteResult $writeResult) 35 { 36 $this->writeResult = $writeResult; 37 $this->isAcknowledged = $writeResult->isAcknowledged(); 38 } 39 40 /** 41 * Return the number of documents that were deleted. 42 * 43 * This method should only be called if the write was acknowledged. 44 * 45 * @see DeleteResult::isAcknowledged() 46 * @return integer|null 47 * @throws BadMethodCallException is the write result is unacknowledged 48 */ 49 public function getDeletedCount() 50 { 51 if ($this->isAcknowledged) { 52 return $this->writeResult->getDeletedCount(); 53 } 54 55 throw BadMethodCallException::unacknowledgedWriteResultAccess(__METHOD__); 56 } 57 58 /** 59 * Return whether this delete was acknowledged by the server. 60 * 61 * If the delete was not acknowledged, other fields from the WriteResult 62 * (e.g. deletedCount) will be undefined. 63 * 64 * @return boolean 65 */ 66 public function isAcknowledged() 67 { 68 return $this->isAcknowledged; 69 } 70 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body