php-doc-en/reference/mongo/mongocollection/getindexinfo.xml
Jeremy Mikola 96ac68c599 Fix example output for MongoCollection::getIndexInfo()
The previous output looked nothing like var_dump(). The indexes are are comparable to those in the previous example, although there are some additional fields and I changed the geo-spatial index to "2dsphere".


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@335757 c90b9560-bf6c-de11-be94-00142212c4b1
2015-01-15 16:24:54 +00:00

149 lines
3.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="mongocollection.getindexinfo" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>MongoCollection::getIndexInfo</refname>
<refpurpose>Returns information about indexes on this collection</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>array</type><methodname>MongoCollection::getIndexInfo</methodname>
<void/>
</methodsynopsis>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
This function returns an array in which each element describes an index.
Elements will contain the values <literal>name</literal> for the name of
the index, <literal>ns</literal> for the namespace (a combination of the
database and collection name), and <literal>key</literal> for a list of all
fields in the index and their ordering. Additional values may be present for
special indexes, such as <literal>unique</literal> or
<literal>sparse</literal>.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>MongoCollection::getIndexInfo</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$m = new MongoClient();
$c = $m->selectCollection('test', 'venues');
var_dump($c->getIndexInfo());
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
array(4) {
[0]=>
array(4) {
["v"]=>
int(1)
["key"]=>
array(1) {
["_id"]=>
int(1)
}
["name"]=>
string(4) "_id_"
["ns"]=>
string(11) "test.venues"
}
[1]=>
array(4) {
["v"]=>
int(1)
["key"]=>
array(1) {
["name"]=>
float(1)
}
["name"]=>
string(6) "name_1"
["ns"]=>
string(11) "test.venues"
}
[2]=>
array(4) {
["v"]=>
int(1)
["key"]=>
array(2) {
["type"]=>
float(1)
["createdAt"]=>
float(-1)
}
["name"]=>
string(19) "type_1_createdAt_-1"
["ns"]=>
string(11) "test.venues"
}
[3]=>
array(5) {
["v"]=>
int(1)
["key"]=>
array(1) {
["location"]=>
string(8) "2dsphere"
}
["name"]=>
string(17) "location_2dsphere"
["ns"]=>
string(11) "test.venues"
["2dsphereIndexVersion"]=>
int(2)
}
}
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
MongoDB core docs on
<link xlink:href="&url.mongodb.dochub.indexes;">vanilla indexes</link> and
<link xlink:href="&url.mongodb.dochub.geo;">geospatial indexes</link>.
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->