downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

MongoDB::prevError> <MongoDB::lastError
[edit] Last updated: Fri, 24 Feb 2012

view this page in

MongoDB::listCollections

(PECL mongo >=0.9.0)

MongoDB::listCollectionsGet a list of collections in this database

Descrição

public array MongoDB::listCollections ( void )

Parâmetros

Esta função não contém parâmetros.

Valor Retornado

Returns a list of MongoCollections.

Exemplos

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

?>

O exemplo acima irá imprimir algo similar a:

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


add a note add a note User Contributed Notes MongoDB::listCollections
Matt Saunders 11-Jan-2010 08:11
Currently, the PHP equivalent to "show dbs" is:

$db->command(array("listDatabases" => 1));

According to kristina1 in #mongodb, there will be a proper helper (listDatabases() I presume ) for this command in a later version.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites