PHP Doku:: Get a list of collections in this database - mongodb.listcollections.html

Verlauf / Chronik / History: (2) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAnbieterspezifische DatenbankerweiterungenMongoDB Native DriverCore ClassesThe MongoDB classMongoDB::listCollections

Ein Service von Reinhard Neidl - Webprogrammierung.

The MongoDB class

<<MongoDB::lastError

MongoDB::prevError>>

MongoDB::listCollections

(PECL mongo >=0.9.0)

MongoDB::listCollectionsGet a list of collections in this database

Beschreibung

public array MongoDB::listCollections ( void )

Parameter-Liste

Diese Funktion hat keine Parameter.

Rückgabewerte

Returns a list of MongoCollections.

Beispiele

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

?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

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

Ein BenutzerBeitrag:
- Beiträge aktualisieren...
Matt Saunders
11.01.2010 17: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.



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)