From cdf45f173634f6ff055ff84f0f472b27e381b49a Mon Sep 17 00:00:00 2001 From: Kristina Chodorow Date: Tue, 24 Mar 2009 19:05:50 +0000 Subject: [PATCH] trying again git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@277706 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/mongo/mongoid/construct.xml | 97 ++++++++++++++++----------- reference/mongo/mongoid/tostring.xml | 33 +++++---- 2 files changed, 79 insertions(+), 51 deletions(-) diff --git a/reference/mongo/mongoid/construct.xml b/reference/mongo/mongoid/construct.xml index 89ff994c76..41cdaba053 100644 --- a/reference/mongo/mongoid/construct.xml +++ b/reference/mongo/mongoid/construct.xml @@ -1,18 +1,17 @@ - + - + - MongoCode::__construct - Creates a new code object + MongoId::__construct + Creates a new id &reftitle.description; - MongoCode::__construct - stringcode - arrayscopearray() + MongoId::__construct + stringid&null; @@ -22,21 +21,11 @@ - code + id - A string of code. - - - - - - scope - - - - The scope to use for the code. + A string to use as the id. @@ -47,39 +36,71 @@ &reftitle.returnvalues; - Returns a new code object. + Returns a new id. &reftitle.examples; - <function>MongoCode::__construct</function> example - + <function>MongoId::__construct</function> example + This example shows how to create a new id. This is seldom necessary, as the driver adds an id to arrays automatically before storing them in the database. + 4)); -var_dump($code); + $id1 = new MongoId(); + echo "$id1\n"; -?> + $id1 = new MongoId(); + echo "$id2\n"; + + ?> ]]> - - &example.outputs.similar; - + + &example.outputs.similar; + - array(1) { - ["x"]=> - int(4) - } - ["code"]=> - string(80) "function(x) { for(i=0;i<10;i++) { db.foo.update({x:i}, {x:i+1}); } return x-1; }" -} +49a7011a05c677b9a916612a +49a702d5450046d3d515d10d ]]> - + + + Note that the second hexidecimal number is greater than the first. + + + Parameter example + This example shows how to use a string parameter to initialize a MongoId with a given value. + + +]]> + + &example.outputs.similar; + + + + + + + + &reftitle.seealso; + + + MongoId::__toString + + diff --git a/reference/mongo/mongoid/tostring.xml b/reference/mongo/mongoid/tostring.xml index 5c22ae86cc..9bbee2eabb 100644 --- a/reference/mongo/mongoid/tostring.xml +++ b/reference/mongo/mongoid/tostring.xml @@ -1,16 +1,16 @@ - + - + - MongoCode::__toString - Returns this code as a string + MongoId::__toString + Returns a hexidecimal representation of this id &reftitle.description; - public stringMongoCode::__toString + public stringMongoId::__toString @@ -23,32 +23,39 @@ &reftitle.returnvalues; - This code, the scope is not returned. + This id. &reftitle.examples; - <function>MongoCode::__toString</function> example + <function>MongoId::__toString</function> example "y" ); -$code = new MongoCode('return x;', array("x"=>"hi")); -echo "$code\n"; +$m = new Mongo(); +$collection = $m->selectDB("foo")->selectCollection("bar"); -$code = new MongoCode('function() { for(i=0;i<10;i++) { db.foo.update({x:i}, {x:i+1}); } }'); -echo "$code\n"; +$collection->insert($obj); +$collection->insert($obj); +$cursor = $collection->find(); +$r1 = cursor->next(); +$r2 = cursor->next(); + +echo $r1["_id"] . "\n"; +echo $r2["_id"] . "\n"; ?> ]]> &example.outputs.similar;