MongoCollection::getIndexInfo

(PECL mongo >=0.9.0)

MongoCollection::getIndexInfoReturns information about indexes on this collection

说明

public MongoCollection::getIndexInfo ( void ) : array

参数

此函数没有参数。

返回值

This function returns an array in which each element describes an index. Elements will contain the values name for the name of the index, ns for the namespace (a combination of the database and collection name), and key for a list of all fields in the index and their ordering. Additional values may be present for special indexes, such as unique or sparse.

范例

Example #1 MongoCollection::getIndexInfo() example

<?php

$m 
= new MongoClient();
$c $m->selectCollection('test''venues');
var_dump($c->getIndexInfo());

?>

以上例程的输出类似于:

array(4) {
  [0]=>
  array(4) {
    ["v"]=>
    int(1)
    ["key"]=>
    array(1) {
      ["_id"]=>
      int(1)
    }
    ["name"]=>
    string(4) "_id_"
    ["ns"]=>
    string(11) "test.venues"
  }
  [1]=>
  array(4) {
    ["v"]=>
    int(1)
    ["key"]=>
    array(1) {
      ["name"]=>
      float(1)
    }
    ["name"]=>
    string(6) "name_1"
    ["ns"]=>
    string(11) "test.venues"
  }
  [2]=>
  array(4) {
    ["v"]=>
    int(1)
    ["key"]=>
    array(2) {
      ["type"]=>
      float(1)
      ["createdAt"]=>
      float(-1)
    }
    ["name"]=>
    string(19) "type_1_createdAt_-1"
    ["ns"]=>
    string(11) "test.venues"
  }
  [3]=>
  array(5) {
    ["v"]=>
    int(1)
    ["key"]=>
    array(1) {
      ["location"]=>
      string(8) "2dsphere"
    }
    ["name"]=>
    string(17) "location_2dsphere"
    ["ns"]=>
    string(11) "test.venues"
    ["2dsphereIndexVersion"]=>
    int(2)
  }
}

参见

MongoDB core docs on » vanilla indexes and » geospatial indexes.

相关文章
php date/time 函数 returns an array with information about sunset/sunrise and twilight begin/endphp gnupg 函数 returns an array with information about all keys that matches the given patternphp semaphore 函数 returns information from the message queue data structurephp mysqlnd memcache 函数 returns information about the plugin configurationphp odbc 函数 returns information about a current connectionphp odbc 函数 retrieves information about data types supported by the data sourcephp paradox 函数 return lots of information about a paradox filephp sqlsrv 函数 returns information about the client and specified connectionphp sqlsrv 函数 returns error and warning information about the last sqlsrv operation performedphp sqlsrv 函数 returns information about the serverphp wincache 函数 retrieves information about files cached in the session cachephp hyperwave api 函数 returns statistics about fulltext serverphp hyperwave api 函数 returns information about server configurationphp mongo returns information about all connection poolsphp mongocollection returns information about indexes on this collectionphp mongocollection returns an array of cursors to iterator over a full collection in parallelphp mongodb driver server returns an array of information about this serverphp mongodb returns information about collections in this databasephp mongopool returns information about all connection poolsphp rrdgraph saves the rrd database query into image and returns the verbose information about generated graph
关注编程学问公众号