From e9d4e36814b3a781d55389337b3cafcd1413a43a Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Tue, 23 Apr 2013 09:27:56 +0000 Subject: [PATCH] PHP-702: Support the autoIndexId option for createCollection git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@330136 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/mongo/mongodb/createcollection.xml | 133 +++++++++++++++---- 1 file changed, 107 insertions(+), 26 deletions(-) diff --git a/reference/mongo/mongodb/createcollection.xml b/reference/mongo/mongodb/createcollection.xml index e3bfbafe1f..d828b2625a 100644 --- a/reference/mongo/mongodb/createcollection.xml +++ b/reference/mongo/mongodb/createcollection.xml @@ -11,10 +11,9 @@ public MongoCollectionMongoDB::createCollection stringname - boolcapped&false; - intsize0 - intmax0 + arrayoptions + This method is used to create capped collections and other collections requiring special options. It is identical to running: @@ -30,8 +29,10 @@ $collection = $db->command(array("create" => $name, "size" => $size, "capped" => See MongoDB::command for more information about database commands. + - &reftitle.parameters; + &reftitle.parameters; + @@ -44,39 +45,72 @@ $collection = $db->command(array("create" => $name, "size" => $size, "capped" => + - capped + options - If the collection should be a fixed size. + An array containing options for the collections. Each option is its own + element in the options array, with the option name listed below being + the key of the element. The supported options depend on the MongoDB + server version. At the moment, the following options are supported: - - - - - size - - - If the collection is fixed size, its size in bytes. + + + + capped + + + + If the collection should be a fixed size. + + + + + + size + + + + If the collection is fixed size, its size in bytes. + + + + + + max + + + + If the collection is fixed size, the maximum number of elements to + store in the collection. + + + + + + autoIndexId + + + + If capped is &true; you can specify &false; to disable the + automatic index created on the _id field. + Before MongoDB 2.2, the default value for + autoIndexId was false. + + + + - - - - max - - - - If the collection is fixed size, the maximum number of elements to store in the collection. - - - + + &reftitle.returnvalues; @@ -103,7 +137,14 @@ $collection = $db->command(array("create" => $name, "size" => $size, "capped" => createCollection("logger", true, 10*1024, 10); +$log = $db->createCollection( + "logger", + array( + 'capped' => true, + 'size' => 10*1024, + 'max' => 10 + ) +); for ($i = 0; $i < 100; $i++) { $log->insert(array("level" => WARN, "msg" => "sample log message #$i", "ts" => new MongoDate())); @@ -133,6 +174,46 @@ sample log message #99 + + + &reftitle.changelog; + + + + + + &Version; + &Description; + + + + + 1.4.0 + + + In versions before 1.4.0, the options were all arguments to the method. The + function synopsis in those older versions is: + + + + public MongoCollectionMongoDB::createCollection + stringname + boolcapped&false; + intsize0 + intmax0 + + + + The meaning of the options is the same as described under the + options argument above. + + + + + + + +