svn: /phpdoc/en/trunk/reference/mongo/ mongocollection/deleteindex.xml mongodb.xml
| From: | Kristina Chodorow | Date: | Tue, 20 Apr 2010 14:49:17 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/mongo/ mongocollection/deleteindex.xml mongodb.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-6404@lists.php.net to get a copy of this message | ||
kristina Tue, 20 Apr 2010 14:49:17 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=298219
Log:
index delete explanation
Changed paths:
U phpdoc/en/trunk/reference/mongo/mongocollection/deleteindex.xml
U phpdoc/en/trunk/reference/mongo/mongodb.xml
Modified: phpdoc/en/trunk/reference/mongo/mongocollection/deleteindex.xml
===================================================================
--- phpdoc/en/trunk/reference/mongo/mongocollection/deleteindex.xml 2010-04-20 14:11:53 UTC (rev
298218)
+++ phpdoc/en/trunk/reference/mongo/mongocollection/deleteindex.xml 2010-04-20 14:49:17 UTC (rev
298219)
@@ -13,6 +13,57 @@
<modifier>public</modifier>
<type>array</type><methodname>MongoCollection::deleteIndex</methodname>
<methodparam><type>string|array</type><parameter>keys</parameter></methodparam>
</methodsynopsis>
+ <para>
+ This method is identical to:
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+public function deleteIndexes($keys) {
+ // toIndexString is a protected method that turns strings, arrays, and objs
+ //into index names
+ $index = $this->toIndexString($keys);
+
+ return $this->db->command(array("deleteIndexes" => $this->getName(),
+ "index" => $index);
+}
+
+?>
+]]>
+ </programlisting>
+ <para>
+ Each index, when created, is given a unique name. This is generally user-set
+ (with <function>MongoCollection::ensureIndex</function>'s "name"
option) or
+ generated by the driver from a combination of key names and directions. This
+ name is then used by <function>MongoCollection::deleteIndex</function> to
+ remove the function.
+ </para>
+ <para>
+ Unfortunately, the <function>MongoCollection::ensureIndex</function>
+ generates slightly different names than the shell and, due to backwards
+ compatibility issues, <function>MongoCollection::deleteIndex</function>
+ cannot delete custom-named indexes as well. Thus, the best way to delete
+ indexes created in the shell or with custom names is to directly call the
+ <literal>deleteIndexes</literal> database command.
+ </para>
+ <para>
+ Thus, if you named an index "superfast query", you could delete it with:
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+$db->command(array("deleteIndexes" => $collection->getName(), "index"
=> "superfast query");
+
+?>
+]]>
+ </programlisting>
+ <para>
+ To find what an index is named, you can query the
+ <literal>system.indexes</literal> collection of a database and look for the
+ <literal>name</literal> field.
+ </para>
</refsect1>
<refsect1 role="parameters">
Modified: phpdoc/en/trunk/reference/mongo/mongodb.xml
===================================================================
--- phpdoc/en/trunk/reference/mongo/mongodb.xml 2010-04-20 14:11:53 UTC (rev 298218)
+++ phpdoc/en/trunk/reference/mongo/mongodb.xml 2010-04-20 14:49:17 UTC (rev 298219)
@@ -17,8 +17,10 @@
<programlisting role="php">
<![CDATA[
<?php
+
$m = new Mongo(); // connect
$db = $m->selectDB("example");
+
?>
]]>
</programlisting>