定义
参数
$options: array指定所需选项的数组。
名称类型说明comment
混合
加密字段
数组|对象
会话
与操作相关联的客户端会话。
1.3版本新增。
typeMap
阵列
应用游标的类型映射,决定如何将BSON文档转换为PHP值。默认为集合的类型映射。
这将用于返回的命令结果文档。
writeConcern
Write concern to use for the operation. Defaults to the collection's write concern.
无法将单个操作的写关注(write concern)指定为ACID 事务的一部分。相反,请在启动ACID 事务时设立
writeConcern选项。
Return Values
An array or object with the result document of the drop command. The return type will depend on the typeMap option.
错误/异常
MongoDB\Exception\UnsupportedException,如果所选服务器使用了选项但不支持选项(例如collation、readConcern、writeConcern)。
MongoDB\Exception\InvalidArgumentException 用于与参数或选项解析相关的错误。
MongoDB\ 驱动程序\Exception\RuntimeException 用于扩展级别的其他错误(例如连接错误)。
例子
以下操作会删除test数据库中的restaurantscollection:
$collection = (new MongoDB\Client)->test->restaurants; $result = $collection->drop(); var_dump($result);
而输出将类似如下所示:
object(MongoDB\Model\BSONDocument)#9 (1) { ["storage":"ArrayObject":private]=> array(3) { ["ns"]=> string(16) "test.restaurants" ["nIndexesWas"]=> int(3) ["ok"]=> float(1) } }
另请参阅
drop command reference in the MongoDB manual