/**
  * Return the number of documents that were inserted.
  *
  * This method should only be called if the write was acknowledged.
  *
  * @see InsertManyResult::isAcknowledged()
  * @return integer
  * @throws BadMethodCallException is the write result is unacknowledged
  */
 public function getInsertedCount()
 {
     if ($this->isAcknowledged) {
         return $this->writeResult->getInsertedCount();
     }
     throw BadMethodCallException::unacknowledgedWriteResultAccess(__METHOD__);
 }
 /**
  * Return the ID of the document inserted by an upsert operation.
  *
  * This value is undefined (i.e. null) if an upsert did not take place.
  *
  * This method should only be called if the write was acknowledged.
  *
  * @see UpdateResult::isAcknowledged()
  * @return mixed|null
  * @throws BadMethodCallException is the write result is unacknowledged
  */
 public function getUpsertedId()
 {
     if ($this->isAcknowledged) {
         foreach ($this->writeResult->getUpsertedIds() as $id) {
             return $id;
         }
         return null;
     }
     throw BadMethodCallException::unacknowledgedWriteResultAccess(__METHOD__);
 }
Example #3
0
 /**
  * Not supported.
  *
  * @see http://php.net/arrayaccess.offsetunset
  * @throws BadMethodCallException
  */
 public function offsetUnset($key)
 {
     throw BadMethodCallException::classIsImmutable(__CLASS__);
 }