From 4cb981d8272dc68fff802f55f2dd68e68182eeaa Mon Sep 17 00:00:00 2001 From: Kristina Chodorow Date: Tue, 2 Jun 2009 17:53:23 +0000 Subject: [PATCH] count and examples, removed util git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@281555 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/mongo/book.xml | 3 +- reference/mongo/mongocode/construct.xml | 32 +++++++++--- reference/mongo/mongocollection/count.xml | 60 +++++++++++++++++++++-- reference/mongo/mongocursor/count.xml | 48 ++++++++++++++++++ reference/mongo/versions.xml | 7 ++- 5 files changed, 134 insertions(+), 16 deletions(-) create mode 100644 reference/mongo/mongocursor/count.xml diff --git a/reference/mongo/book.xml b/reference/mongo/book.xml index 5bb8d5f402..8273bcadad 100644 --- a/reference/mongo/book.xml +++ b/reference/mongo/book.xml @@ -1,5 +1,5 @@ - + Mongo @@ -39,7 +39,6 @@ &reference.mongo.mongogridfs; &reference.mongo.mongogridfsfile; &reference.mongo.mongogridfscursor; - &reference.mongo.mongoutil; &reference.mongo.mongoid; &reference.mongo.mongocode; diff --git a/reference/mongo/mongocode/construct.xml b/reference/mongo/mongocode/construct.xml index 89ff994c76..15d4b7bb03 100644 --- a/reference/mongo/mongocode/construct.xml +++ b/reference/mongo/mongocode/construct.xml @@ -1,5 +1,5 @@ - + @@ -54,8 +54,8 @@ &reftitle.examples; - <function>MongoCode::__construct</function> example - + <function>MongoCode::__construct</function> example + ]]> - - &example.outputs.similar; - + + &example.outputs.similar; + @@ -78,7 +78,25 @@ object(MongoCode)#1 (2) { string(80) "function(x) { for(i=0;i<10;i++) { db.foo.update({x:i}, {x:i+1}); } return x-1; }" } ]]> - + + + + + + Using <function>MongoCode</function> with $where + + This example queries a collection for elements where the 'x' fields is less than $y. Notice that + PHP objects can be passed into the JavaScript scope and that the JavaScript function returns a boolean. + + +find(array('$where' => new MongoCode('function() { return this.x < y; }', array('y'=>$y)))); + +?> +]]> + diff --git a/reference/mongo/mongocollection/count.xml b/reference/mongo/mongocollection/count.xml index 0648cee45b..7cf82bde20 100644 --- a/reference/mongo/mongocollection/count.xml +++ b/reference/mongo/mongocollection/count.xml @@ -1,6 +1,6 @@ - + MongoCollection::count @@ -11,13 +11,37 @@ &reftitle.description; public intMongoCollection::count - + arrayqueryarray() + arrayfieldsarray() &reftitle.parameters; - &no.function.parameters; + + + + + query + + + + Only count documents matching this query. + + + + + + fields + + + + Only count documents with these fields. + + + + + @@ -26,6 +50,36 @@ Returns the number of documents. + + + &reftitle.examples; + + <function>MongoCollection::count</function> example + +insert(array('x'=>1)); +$collection->insert(array('x'=>2)); +$collection->insert(array('x'=>3, 'y'=>1)); + +var_dump($collection->count()); +var_dump($collection->count(array('x'=>1))); +var_dump($collection->count(array(), array('z'=>1))); + +?> +]]> + + &example.outputs.similar; + + + + + + + + MongoCursor::count + Counts the number of results for this query + + + + &reftitle.description; + + public intMongoCursor::count + + + + + + &reftitle.parameters; + &no.function.parameters; + + + + &reftitle.returnvalues; + + The number of documents returned by this cursor's query. + + + + diff --git a/reference/mongo/versions.xml b/reference/mongo/versions.xml index e67134c730..3d338176cb 100644 --- a/reference/mongo/versions.xml +++ b/reference/mongo/versions.xml @@ -1,5 +1,5 @@ - + @@ -39,6 +39,7 @@ + @@ -74,9 +75,7 @@ - - - +