<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Returns information about indexes on this collection</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mongocollection.getdbref.html">MongoCollection::getDBRef</a></div> <div class="next" style="text-align: right; float: right;"><a href="mongocollection.getname.html">MongoCollection::getName</a></div> <div class="up"><a href="class.mongocollection.html">MongoCollection</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="mongocollection.getindexinfo" class="refentry"> <div class="refnamediv"> <h1 class="refname">MongoCollection::getIndexInfo</h1> <p class="verinfo">(PECL mongo >=0.9.0)</p><p class="refpurpose"><span class="refname">MongoCollection::getIndexInfo</span> — <span class="dc-title">Returns information about indexes on this collection</span></p> </div> <div class="refsect1 description" id="refsect1-mongocollection.getindexinfo-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><strong>MongoCollection::getIndexInfo</strong></span> ( <span class="methodparam">void</span> )</div> </div> <div class="refsect1 parameters" id="refsect1-mongocollection.getindexinfo-parameters"> <h3 class="title">Parameters</h3> <p class="para">This function has no parameters.</p> </div> <div class="refsect1 returnvalues" id="refsect1-mongocollection.getindexinfo-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> This function returns an array in which each element describes an index. Elements will contain the values <em>name</em> for the name of the index, <em>ns</em> for the namespace (a combination of the database and collection name), and <em>key</em> for a list of all fields in the index and their ordering. Additional values may be present for special indexes, such as <em>unique</em> or <em>sparse</em>. </p> </div> <div class="refsect1 examples" id="refsect1-mongocollection.getindexinfo-examples"> <h3 class="title">Examples</h3> <div class="example" id="example-1456"> <p><strong>Example #1 <span class="function"><strong>MongoCollection::getIndexInfo()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br />$m </span><span style="color: #007700">= new </span><span style="color: #0000BB">MongoClient</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$c </span><span style="color: #007700">= </span><span style="color: #0000BB">$m</span><span style="color: #007700">-></span><span style="color: #0000BB">selectCollection</span><span style="color: #007700">(</span><span style="color: #DD0000">'test'</span><span style="color: #007700">, </span><span style="color: #DD0000">'venues'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">-></span><span style="color: #0000BB">getIndexInfo</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output something similar to:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> array( 0 => array( "v" => 1, "key" => array( "_id" => 1, ), "ns" => "test.venues", "name" => "_id_", ), 1 => array( "v" => 1, "key" => array( "name" => 1, ), "unique" : true, "ns" => "test.venues", "name" => "name_1", ), 2 => array( "v" => 1, "key" => array( "type" => 1, "createdAt" => -1, ), "ns" => "test.venues", "name" => "type_1_createdAt_-1", ), 3 => array( "v" => 1, "key" => array( "location" => "2d", ), "ns" => "test.venues", "name" => "location_2d", ), ) </pre></div> </div> </div> </div> <div class="refsect1 seealso" id="refsect1-mongocollection.getindexinfo-seealso"> <h3 class="title">See Also</h3> <p class="para"> MongoDB core docs on <a href="http://docs.mongodb.org/manual/indexes/" class="link external">» vanilla indexes</a> and <a href="http://docs.mongodb.org/manual/applications/geospatial-indexes/" class="link external">» geospatial indexes</a>. </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mongocollection.getdbref.html">MongoCollection::getDBRef</a></div> <div class="next" style="text-align: right; float: right;"><a href="mongocollection.getname.html">MongoCollection::getName</a></div> <div class="up"><a href="class.mongocollection.html">MongoCollection</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>