1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace MongoDB\Operation;
use MongoDB\Driver\Command;
use MongoDB\Driver\Server;
/**
* Operation for the dropDatabase command.
*
* @api
* @see MongoDB\Client::dropDatabase()
* @see MongoDB\Database::drop()
* @see http://docs.mongodb.org/manual/reference/command/dropDatabase/
*/
class DropDatabase implements Executable
{
private $databaseName;
/**
* Constructs a dropDatabase command.
*
* @param string $databaseName Database name
*/
public function __construct($databaseName)
{
$this->databaseName = (string) $databaseName;
}
/**
* Execute the operation.
*
* @see Executable::execute()
* @param Server $server
* @return object Command result document
*/
public function execute(Server $server)
{
$cursor = $server->executeCommand($this->databaseName, new Command(['dropDatabase' => 1]));
return current($cursor->toArray());
}
}