MongoCollection
PHP Manual

MongoCollection::ensureIndex

(PECL mongo >=0.9.0)

MongoCollection::ensureIndex Crée un index sur un champ donné

Description

public boolean MongoCollection::ensureIndex ( string|array $keys )

Liste de paramètres

keys

Le ou les champs à indexer.

Valeurs de retour

Returns TRUE.

Exemples

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));

?>

MongoCollection
PHP Manual