php-doc-en/reference/mongo/mongocollection/getindexinfo.xml

123 lines
2.9 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(
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",
),
)
]]>
</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
-->