MongoCollection
PHP Manual

MongoCollection::getIndexInfo

(PECL mongo >=0.9.0)

MongoCollection::getIndexInfoこのコレクションのインデックスについての情報を返す

説明

public array MongoCollection::getIndexInfo ( void )

パラメータ

この関数にはパラメータはありません。

返り値

この関数は、配列を返します。配列の各要素が、それぞれ配列になっています。 その要素には、インデックス名を表す name や名前空間 (コレクション名) を表す ns、すべてのキーとそのソート順 (インデックスを作るもの) を表す key、 そしてこのインデックスの ID を表す MongoID オブジェクトを含む _id があります。

例1 MongoCollection::find() の例

この例では、範囲検索の方法を説明します。

<?php

$m 
= new Mongo;
$c $m->selectCollection('project''outfits');
var_dump($c->getIndexInfo());

?>

上の例の出力は以下となります。

array(8) {
  [0] =>
  array(3) {
    'name' =>
    string(4) '_id_'
    'ns' =>
    string(12) 'project.outfits'
    'key' =>
    array(1) {
      '_id' =>
      int(1)
    }
  }
...
  [7] =>
  array(4) {
    '_id' =>
    class MongoId#12 (1) {
      public $$id =>      string(24) '4d6f7abd44670a1513190000'
    }
    'ns' =>
    string(12) 'project.outfits'
    'key' =>
    array(2) {
      'created' =>
      int(-1)
      'userid' =>
      int(1)
    }
    'name' =>
    string(19) 'created_-1_userid_1'
  }
}

カーソルの動きに関する詳細な情報は MongoCursor を参照ください。


MongoCollection
PHP Manual