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

MongoDB\Model\IndexInfo::getKey()

本页内容

  • 定义
  • 返回值
  • 示例
  • 另请参阅
MongoDB\Model\IndexInfo::getKey()

返回索引规范(即索引字段和顺序)。这与 MongoDB\Collection::createIndex() 的 $key 参数相对应。MongoDB\Collection::createIndex().

function getKey(): array

索引规范作为关联数组。

<?php
$info = new IndexInfo([
'key' => ['x' => 1],
]);
var_dump($info->getKey());

输出结果将类似于

array(1) {
["x"]=>
int(1)
}
  • MongoDB\Collection::createIndex()

  • listIndexes 命令参考,位于MongoDB手册中

返回

IndexInfo 类