MongoClient::selectCollection

(PECL mongo >=1.3.0)

MongoClient::selectCollection获取数据库的文档集

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:

说明

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

参数

db

数据库名

collection

文档集名。

返回值

返回一个新的文档集对象。

错误/异常

如果数据库或文档集名称是无效的,抛出 Exception

范例

Example #1 MongoClient::selectCollection() 例子

<?php
$m 
= new MongoClient();

$c1 $m->selectCollection("foo""bar.baz");
// 就等于
$c2 $m->selectDB("foo")->selectCollection("bar.baz");

// $c1 和 $c2 现在表示的是同一个文档集
?>

User Contributed Notes

There are no user contributed notes for this page.