MongoDB
PHP Manual

MongoDB::listCollections

(PECL mongo >=0.9.0)

MongoDB::listCollectionsGet a list of collections in this database

说明

public array MongoDB::listCollections ( void )

参数

此函数没有参数。

返回值

Returns a list of MongoCollections.

范例

Example #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";
}

?>

以上例程的输出类似于:

removing sample.blog.posts... gone
removing sample.critical.docs... gone
removing sample.taxes... gone
...

MongoDB
PHP Manual