MongoDB\GridFS\Bucket::delete()
定义
参数
$id
: 混合类型- 要删除的文件的
_id
。
错误/异常
如果没有找到符合选择条件的文件,则会出现MongoDB\GridFS\Exception\FileNotFoundException
。
对于扩展级别的其他错误(例如连接错误),请参阅MongoDB\Driver\Exception\RuntimeException。
行为
如果未找到文件集合文档,此方法仍将尝试删除孤立的块。
示例
$bucket = (new MongoDB\Client)->test->selectGridFSBucket(); $stream = fopen('php://temp', 'w+b'); fwrite($stream, "foobar"); rewind($stream); $id = $bucket->uploadFromStream('filename', $stream); $bucket->delete($id);