MongoCollection::getIndexInfo

(PECL mongo >=0.9.0)

MongoCollection::getIndexInfoReturns information about indexes on this collection

Описание

public array MongoCollection::getIndexInfo ( void )

Список параметров

У этой функции нет параметров.

Возвращаемые значения

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.

Примеры

Пример #1 MongoCollection::getIndexInfo() example

<?php

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

?>

Результатом выполнения данного примера будет что-то подобное:

array(
  0 => array(
    "v" => 1,
    "key" => array(
      "_id" => 1,
    ),
    "ns" => "test.venues",
    "name" => "_id_",
  ),
  1 => array(
    "v" => 1,
    "key" => array(
      "name" => 1,
    ),
    "unique" : true,
    "ns" => "test.venues",
    "name" => "name_1",
  ),
  2 => array(
    "v" => 1,
    "key" => array(
      "type" => 1,
      "createdAt" => -1,
    ),
    "ns" => "test.venues",
    "name" => "type_1_createdAt_-1",
  ),
  3 => array(
    "v" => 1,
    "key" => array(
      "location" => "2d",
    ),
    "ns" => "test.venues",
    "name" => "location_2d",
  ),
)

Смотрите также

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

Коментарии

<?php
/*
    For example, to view all indexes on the people collection from country databse :
    InmongoDb
    use country
    db.people.getIndexes()
    Inphp
 
*/
$m = new MongoClient();
$indexes $m->country->people->getIndexInfo();

?>
2013-10-06 01:50:55
http://php5.kiev.ua/manual/ru/mongocollection.getindexinfo.html

    Поддержать сайт на родительском проекте КГБ