MongoCollection::drop
MongoCollection::find
MongoCollection
PHP Manual

# MongoCollection::ensureIndex

(PECL mongo >=0.9.0)

MongoCollection::ensureIndex — Creates an index on the given field(s), or does nothing if the index already exists

### Descripción

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

### Lista de parámetros

`keys`

  Field or fields to use as index.

### Valores retornados

Returns `TRUE`.

### Ejemplos

Example #1 MongoCollection::ensureIndex() example

`<?php
$c = new MongoCollection($db, 'foo');
// create an index on 'x' ascending
$c->ensureIndex('x');
// create an index on 'y' ascending
$c->ensureIndex(array('y' => 1));
// create an index on 'w' descending
$c->ensureIndex(array('w' => -1));
// create an index on 'z' ascending and 'zz' descending
$c->ensureIndex(array('z' => 1, 'zz' => -1));
?>`

MongoCollection::drop
MongoCollection::find
MongoCollection
PHP Manual