From 83d670adaa1c2320bedfb0f5c47e0aa703ba5cce Mon Sep 17 00:00:00 2001 From: Kristina Chodorow Date: Thu, 25 Mar 2010 17:47:33 +0000 Subject: [PATCH] $ operator and geospatial indexes git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@296798 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../mongo/mongocollection/ensureindex.xml | 22 ++++++++++++++++++- reference/mongo/updates.xml | 21 ++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/reference/mongo/mongocollection/ensureindex.xml b/reference/mongo/mongocollection/ensureindex.xml index d9dcce1c9b..fc2bb80283 100644 --- a/reference/mongo/mongocollection/ensureindex.xml +++ b/reference/mongo/mongocollection/ensureindex.xml @@ -186,6 +186,24 @@ $collection->ensureIndex(array("username" => 1), array("unique" => 1, "dropDups" */ $collection->insert(array("username" => "joeschmoe")); +?> +]]> + + + + + Geospatial Indexing + + 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: + + +ensureIndex(array("loc" => "2d")); + ?> ]]> @@ -195,7 +213,9 @@ $collection->insert(array("username" => "joeschmoe")); &reftitle.seealso; - MongoDB core docs on indexes. + MongoDB core docs on + vanilla indexes and + geospatial indexes. diff --git a/reference/mongo/updates.xml b/reference/mongo/updates.xml index 52ead6501d..da7933ce21 100644 --- a/reference/mongo/updates.xml +++ b/reference/mongo/updates.xml @@ -52,6 +52,27 @@ $blog->update($criteria, array('$set' => array("comments.1" => array("author" => + +
+ The Positional Operator + + The positional operator $ 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 $ to do so. + + +update( + array("comments.author" => "John"), + array('$set' => array('comments.$.author' => "Jim"))); + +?> +]]> + +