mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
unique index
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@290067 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
08933385d1
commit
fd703dceda
1 changed files with 17 additions and 0 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue