mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
$ operator and geospatial indexes
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@296798 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
281e4d59bf
commit
83d670adaa
2 changed files with 42 additions and 1 deletions
|
@ -186,6 +186,24 @@ $collection->ensureIndex(array("username" => 1), array("unique" => 1, "dropDups"
|
|||
*/
|
||||
$collection->insert(array("username" => "joeschmoe"));
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>Geospatial Indexing</title>
|
||||
<para>
|
||||
Mongo supports geospatial indexes, which allow you to search for documents
|
||||
near a given location or within a shape. For example, to create a
|
||||
geospatial index on the "loc" field:
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$collection->ensureIndex(array("loc" => "2d"));
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
@ -195,7 +213,9 @@ $collection->insert(array("username" => "joeschmoe"));
|
|||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
MongoDB core docs on <link xlink:href="&url.mongodb.dochub.indexes;">indexes</link>.
|
||||
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>
|
||||
|
||||
|
|
|
@ -52,6 +52,27 @@ $blog->update($criteria, array('$set' => array("comments.1" => array("author" =>
|
|||
</programlisting>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>The Positional Operator</title>
|
||||
<para>
|
||||
The positional operator <literal>$</literal> is useful for updating objects
|
||||
that are in arrays. In the example above, for instance, suppose that we did
|
||||
not know the index of the comment that we needed to change, merely that we
|
||||
needed to change "John" to "Jim". We can use <literal>$</literal> to do so.
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$blog->update(
|
||||
array("comments.author" => "John"),
|
||||
array('$set' => array('comments.$.author' => "Jim")));
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
Loading…
Reference in a new issue