MongoClient::selectCollection

(PECL mongo >=1.3.0)

MongoClient::selectCollectionGets a database collection

This extension that defines this method is deprecated. Instead, the MongoDB extension should be used. There is no equivalent for this method in the new extension, but there is an alternative in the PHP library:

Description

public MongoClient::selectCollection ( string $db , string $collection ) : MongoCollection

Parameters

db

The database name.

collection

The collection name.

Return Values

Returns a new collection object.

Errors/Exceptions

Throws Exception if the database or collection name is invalid.

Examples

Example #1 MongoClient::selectCollection() example

<?php
$m 
= new MongoClient();

$c1 $m->selectCollection("foo""bar.baz");
// which is equivalent to
$c2 $m->selectDB("foo")->selectCollection("bar.baz");

// $c1 and $c2 now represent the same collection
?>
add a note add a note

User Contributed Notes

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