MongoDB::listCollections

(PECL mongo >=0.9.0)

MongoDB::listCollectionsGet a list of collections in this database

Beskrivelse

public array MongoDB::listCollections ( void )

Parametre

This function has no parameters.

Returnerings Værdier

Returns a list of MongoCollections.

Eksempler

Eksempel #1 MongoDB::listCollections() example

The following example demonstrates dropping each collection in a database.

<?php

$m 
= new Mongo();
$db $m->selectDB("sample");

$list $db->listCollections();
foreach (
$list as $collection) {
    echo 
"removing $collection... ";
    
$collection->drop();
    echo 
"gone\n";
}

?>

The above example will output something similar to:

removing sample.blog.posts... gone
removing sample.critical.docs... gone
removing sample.taxes... gone
...
add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top