PHP - Manual: MongoClient::selectCollection
2024-11-14
(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:
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 现在表示的是同一个文档集
?>
官方地址:https://www.php.net/manual/en/mongoclient.selectcollection.php