(PECL mongo >=0.9.0)
MongoCollection::ensureIndex — Crée un index sur un champ donné
Le ou les champs à indexer.
Returns TRUE.
Exemple #1 Exemple avec MongoCollection::ensureIndex()
<?php
$c = new MongoCollection($db, 'foo');
// crée un index ascendant sur 'x'
$c->ensureIndex('x');
// crée un index ascendant sur 'y'
$c->ensureIndex(array('y' => 1));
// crée un index descendant sur 'w'
$c->ensureIndex(array('w' => -1));
// crée un index ascendant sur 'z' et descendant sur 'zz'
$c->ensureIndex(array('z' => 1, 'zz' => -1));
?>