Changed example to be non-destructive.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@334840 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Derick Rethans 2014-09-11 11:50:19 +00:00
parent 2bf617982f
commit 6133457550

View file

@ -68,20 +68,19 @@
<example>
<title><function>MongoDB::listCollections</function> example</title>
<para>
The following example demonstrates dropping each collection in a database.
The following example demonstrates running count on each collection in a database.
</para>
<programlisting role="php">
<![CDATA[
<?php
$m = new MongoClient();
$db = $m->selectDB("sample");
$db = $m->selectDB("demo");
$list = $db->listCollections();
foreach ($list as $collection) {
echo "removing $collection... ";
$collection->drop();
echo "gone\n";
echo "amount of documents in $collection: ";
echo $collection->count(), "\n";
}
?>
@ -90,9 +89,10 @@ foreach ($list as $collection) {
&example.outputs.similar;
<screen>
<![CDATA[
removing sample.blog.posts... gone
removing sample.critical.docs... gone
removing sample.taxes... gone
...
amount of documents in demo.pubs: 4
amount of documents in demo.elephpants: 3
amount of documents in demo.cities: 22840
...
]]>
</screen>