From fd703dceda516eabc9b693987951bae4f94a1f07 Mon Sep 17 00:00:00 2001 From: Kristina Chodorow Date: Thu, 29 Oct 2009 22:45:05 +0000 Subject: [PATCH] unique index git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@290067 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/mongo/mongocollection/ensureindex.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/reference/mongo/mongocollection/ensureindex.xml b/reference/mongo/mongocollection/ensureindex.xml index 8dfe5c2781..5924088eca 100644 --- a/reference/mongo/mongocollection/ensureindex.xml +++ b/reference/mongo/mongocollection/ensureindex.xml @@ -15,7 +15,11 @@ public booleanMongoCollection::ensureIndex string|arraykeys + booleanunique + + A unique index cannot be created on a field if multiple existing documents do not contain the field. The field is effectively &null; for these documents and thus already non-unique. + @@ -32,6 +36,16 @@ + + + unique + + + + If the index should be unique. + + + @@ -65,6 +79,9 @@ $c->ensureIndex(array('w' => -1)); // create an index on 'z' ascending and 'zz' descending $c->ensureIndex(array('z' => 1, 'zz' => -1)); +// create a unique index on 'x' +$c->ensureIndex(array('x' => 1), true); + ?> ]]>