From a33cd08acaa764c17d9c54c70d9698433180c1c0 Mon Sep 17 00:00:00 2001 From: Kristina Chodorow Date: Mon, 8 Mar 2010 15:42:26 +0000 Subject: [PATCH] added MongoCursor::getQuery and recursive warning git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@295967 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/mongo/datatypes.xml | 28 ------- reference/mongo/mongocursor/getquery.xml | 93 ++++++++++++++++++++++ reference/mongo/types.xml | 98 +++++++++++++++--------- reference/mongo/versions.xml | 1 + 4 files changed, 157 insertions(+), 63 deletions(-) delete mode 100644 reference/mongo/datatypes.xml create mode 100644 reference/mongo/mongocursor/getquery.xml diff --git a/reference/mongo/datatypes.xml b/reference/mongo/datatypes.xml deleted file mode 100644 index b7d715425e..0000000000 --- a/reference/mongo/datatypes.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- Data Types - -
- - diff --git a/reference/mongo/mongocursor/getquery.xml b/reference/mongo/mongocursor/getquery.xml new file mode 100644 index 0000000000..4d203739ce --- /dev/null +++ b/reference/mongo/mongocursor/getquery.xml @@ -0,0 +1,93 @@ + + + + + + MongoCursor::getQuery + Gets the query, fields, limit, and skip for this cursor + + + + &reftitle.description; + + public arrayMongoCursor::getQuery + + + + This can be called before or after the query. + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + The query, fields, limit, and skip for this cursor as an associative array. + + + + + &reftitle.examples; + + <function>MongoCursor::getQuery</function> example + +foo->bar->find(array("x" => 4), array("y" => false)); +var_dump($cursor->getQuery()); + +?> +]]> + + &example.outputs.similar; + + + string(7) "foo.bar" + ["limit"]=> + int(0) + ["skip"]=> + int(0) + ["query"]=> + array(1) { + ["x"]=> + int(4) + } + ["fields"]=> + array(1) { + ["y"]=> + int(0) + } +} +]]> + + + + + + diff --git a/reference/mongo/types.xml b/reference/mongo/types.xml index 1fe356d330..abdfb42396 100644 --- a/reference/mongo/types.xml +++ b/reference/mongo/types.xml @@ -14,37 +14,6 @@ a half-dozen classes provided by the MongoDB PHP driver (for regular expressions, dates, and other specialized applications). - - MongoDB uses a storage format called "BSON," Binary Serializable Object - Notation, which is similar to JSON but more compact and rich in types. Listed - below is the exact byte size of each type (or information required to compute - its size, in the case of variable-length types). Keep in mind that these - sizes do not include field names. The size of an object can be manually - computed, but it may be easier for programmers to call the - bson_encode function and take the length of the resulting - string. - - - An example of manually computing BSON size for saving the object - array("x" => null, "y" => 40): - - - -
@@ -107,9 +76,9 @@ insert(array("scores" => $scores); +// $scores will be saved as an array +$scores = array(98, 100, 73, 85); +$collection->insert(array("scores" => $scores); // $scores will be saved as an object $scores = array("quiz1" => 98, "midterm" => 100, "quiz2" => 73, "final" => 85); @@ -181,13 +150,36 @@ $blog->insert($post2); From the database shell, this will look something like: - db.blog.find() { "_id" : ObjectId("4b06c263edb87a281e09dad8"), "author" : "Adam", "content" : "This is a blog post", "comments" : [ ], "date" : "Fri Nov 20 2009 11:22:59 GMT-0500 (EST)" } { "_id" : ObjectId("4b06c282edb87a281e09dad9"), "author" : { "name" : "Fred", "karma" : 42 }, "content" : "This is a blog post", "comments" : [ ], "date" : "Fri Nov 20 2009 11:23:30 GMT-0500 (EST)", "title" : "Second Post" } ]]> + + + The driver will not detect reference loops in arrays and objects. For + example, this will give a fatal error: + +insert($GLOBALS); + +?> +]]> + + + + + If you need to insert documents that may have recursive dependency, you have + to check for it yourself before passing it to the driver. +
@@ -321,6 +313,42 @@ $blog->insert($post2);
+ +
+ BSON + + MongoDB uses a storage format called "BSON," Binary Serializable Object + Notation, which is similar to JSON but more compact and rich in types. Listed + below is the exact byte size of each type (or information required to compute + its size, in the case of variable-length types). Keep in mind that these + sizes do not include field names. The size of an object can be manually + computed, but it may be easier for programmers to call the + bson_encode function and take the length of the resulting + string. + + + An example of manually computing BSON size for saving the object + array("x" => null, "y" => 40): + + + + +
+ &reference.mongo.mongoid; diff --git a/reference/mongo/versions.xml b/reference/mongo/versions.xml index 5ec02ccb35..e2cceb2c68 100644 --- a/reference/mongo/versions.xml +++ b/reference/mongo/versions.xml @@ -89,6 +89,7 @@ +