文档菜单
文档首页
/ / /
PHP库手册
/ /

MongoDB\Collection::getNamespace()

本页内容

  • 定义
  • 返回值
  • 示例
  • 另请参阅
MongoDB\Collection::getNamespace()

返回命名空间。命名空间是MongoDB中索引或集合的规范名称。

function getNamespace(): string

该集合的命名空间作为字符串。

以下代码返回 test 数据库中 zips 集合的命名空间。

<?php
$collection = (new MongoDB\Client)->test->zips;
echo $collection->getNamespace();

输出结果可能如下所示

test.zips
  • MongoDB\Collection::getCollectionName()

  • MongoDB\Collection::getDatabaseName()

返回

getManager()