How to perform drop() or remove() and other functions by using MongoDB drivers for php 7?
I refered https://docs.mongodb.org/v3.0/reference/method/js-collection/
but, I am not getting much documentation for PHongo (MongoDB driver for PHP 7).
Thank you in advance.
You can delete a collection like this:
$manager = new \MongoDB\Driver\Manager("mongodb://" . $username . ":" . $password . "@{$host}:{$port}");
$manager->executeCommand('database', new \MongoDB\Driver\Command(["drop" => "collection"]));
or you could follow the instructions in this guide :
$db = (new MongoDB\Client)->demo;
$result = $db->dropCollection('users');
var_dump($result);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.