MongoDB::__get

(PECL mongo >=1.0.2)

MongoDB::__getGets a collection

说明

public MongoDB::__get ( string $name ) : MongoCollection

This is the easiest way of getting a collection from a database object. If a collection name contains strange characters, you may have to use MongoDB::selectCollection() instead.

<?php

$mongo 
= new MongoClient();

// the following two lines are equivalent
$collection $mongo->selectDB("foo")->selectCollection("bar");
$collection $mongo->foo->bar;

?>

参数

name

The name of the collection.

返回值

Returns the collection.