MongoCollection::getIndexInfo
(PECL mongo >=0.9.0)
MongoCollection::getIndexInfo — Returns information about indexes on this collection
Описание
Список параметров
У этой функции нет параметров.
Возвращаемые значения
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(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 Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с базами данных
- Расширения для работы с базами данных отдельных производителей
- MongoDB
- Базовые классы
- Функция MongoCollection::aggregate() - Perform an aggregation using the aggregation framework
- Функция MongoCollection::aggregateCursor() - Execute an aggregation pipeline command and retrieve results through a cursor
- Функция MongoCollection::batchInsert() - Inserts multiple documents into this collection
- Функция MongoCollection::__construct() - Creates a new collection
- Функция MongoCollection::count() - Counts the number of documents in this collection
- Функция MongoCollection::createDBRef() - Creates a database reference
- Функция MongoCollection::createIndex() - Creates an index on the specified field(s) if it does not already exist.
- Функция MongoCollection::deleteIndex() - Deletes an index from this collection
- Функция MongoCollection::deleteIndexes() - Delete all indices for this collection
- Функция MongoCollection::distinct() - Retrieve a list of distinct values for the given key across a collection.
- Функция MongoCollection::drop() - Drops this collection
- Функция MongoCollection::ensureIndex() - Creates an index on the specified field(s) if it does not already exist.
- MongoCollection::find
- Функция MongoCollection::findAndModify() - Update a document and return it
- Функция MongoCollection::findOne() - Queries this collection, returning a single element
- Функция MongoCollection::__get() - Gets a collection
- Функция MongoCollection::getDBRef() - Fetches the document pointed to by a database reference
- Функция MongoCollection::getIndexInfo() - Returns information about indexes on this collection
- Функция MongoCollection::getName() - Returns this collection's name
- Функция MongoCollection::getReadPreference() - Get the read preference for this collection
- Функция MongoCollection::getSlaveOkay() - Get slaveOkay setting for this collection
- Функция MongoCollection::getWriteConcern() - Get the write concern for this collection
- Функция MongoCollection::group() - Performs an operation similar to SQL's GROUP BY command
- Функция MongoCollection::insert() - Inserts a document into the collection
- Функция MongoCollection::parallelCollectionScan() - Returns an array of cursors to iterator over a full collection in parallel
- Функция MongoCollection::remove() - Remove records from this collection
- Функция MongoCollection::save() - Saves a document to this collection
- Функция MongoCollection::setReadPreference() - Set the read preference for this collection
- Функция MongoCollection::setSlaveOkay() - Change slaveOkay setting for this collection
- Функция MongoCollection::setWriteConcern() - Set the write concern for this database
- Функция MongoCollection::toIndexString() - Converts keys specifying an index to its identifying string
- Функция MongoCollection::__toString() - String representation of this collection
- Функция MongoCollection::update() - Update records based on a given criteria
- Функция MongoCollection::validate() - Validates this collection
Коментарии
<?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();
?>