MongoDB::drop

(PECL mongo >=0.9.0)
Drops this database
public array MongoDB::drop ( void )

This drops the database currently being used.

This is identical to running:

1
2
3
4
5
6
7
<?php
 
public function drop() {
    $this->command(array("dropDatabase" => 1));
}
 
?>
Returns:

Returns the database response.

Examples:
MongoDB::drop() example

This example demonstrates how to drop a mongo database and the response to expect.

1
2
3
4
5
6
7
<?php
 
$db $mongo->foo;
$response $db->drop();
print_r($response);
 
?>

The above example will output something similar to:

Array
(
    [dropped] => foo.$cmd
    [ok] => 1
)
doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.