svn: /phpdoc/en/trunk/reference/mongo/mongocollection/ ensureindex.xml
| From: | Kristina Chodorow | Date: | Thu, 29 Oct 2009 22:45:05 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/mongo/mongocollection/ ensureindex.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-5238@lists.php.net to get a copy of this message | ||
kristina Thu, 29 Oct 2009 22:45:05 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=290067
Log:
unique index
Changed paths:
U phpdoc/en/trunk/reference/mongo/mongocollection/ensureindex.xml
Modified: phpdoc/en/trunk/reference/mongo/mongocollection/ensureindex.xml
===================================================================
--- phpdoc/en/trunk/reference/mongo/mongocollection/ensureindex.xml 2009-10-29 22:31:35 UTC (rev
290066)
+++ phpdoc/en/trunk/reference/mongo/mongocollection/ensureindex.xml 2009-10-29 22:45:05 UTC (rev
290067)
@@ -15,7 +15,11 @@
<methodsynopsis>
<modifier>public</modifier>
<type>boolean</type><methodname>MongoCollection::ensureIndex</methodname>
<methodparam><type>string|array</type><parameter>keys</parameter></methodparam>
+
<methodparam><type>boolean</type><parameter>unique</parameter></methodparam>
</methodsynopsis>
+ <para>
+ 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.
+ </para>
</refsect1>
<refsect1 role="parameters">
@@ -32,6 +36,16 @@
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>
+ <parameter>unique</parameter>
+ </term>
+ <listitem>
+ <para>
+ If the index should be unique.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</para>
</refsect1>
@@ -65,6 +79,9 @@
// 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);
+
?>
]]>
</programlisting>