unique index

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@290067 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Kristina Chodorow 2009-10-29 22:45:05 +00:00
parent 08933385d1
commit fd703dceda

View file

@ -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 @@ $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);
?>
]]>
</programlisting>