svn: /phpdoc/en/trunk/reference/mongo/mongocollection/ batchinsert.xml

From: Date: Tue, 06 Mar 2012 19:03:05 +0000
Subject: svn: /phpdoc/en/trunk/reference/mongo/mongocollection/ batchinsert.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-9841@lists.php.net to get a copy of this message
derick Tue, 06 Mar 2012 19:03:05 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=323965 Log: Add an example too. Changed paths: U phpdoc/en/trunk/reference/mongo/mongocollection/batchinsert.xml Modified: phpdoc/en/trunk/reference/mongo/mongocollection/batchinsert.xml =================================================================== --- phpdoc/en/trunk/reference/mongo/mongocollection/batchinsert.xml 2012-03-06 18:58:54 UTC (rev 323964) +++ phpdoc/en/trunk/reference/mongo/mongocollection/batchinsert.xml 2012-03-06 19:03:05 UTC (rev 323965) @@ -195,6 +195,60 @@ ]]> </screen> </example> + + <example> + <title><function>MongoCollection::batchInsert</function> example with + ignoring errors</title> + <programlisting role="php"> +<![CDATA[ +<?php + +$con = new Mongo; +$db = $con->demo; + +$doc1 = array( + '_id' => new MongoId('4cb4ab6d7addf98506010001'), + 'id' => 1, + 'desc' => "ONE", +); +$doc2 = array( + '_id' => new MongoId('4cb4ab6d7addf98506010002'), + 'id' => 2, + 'desc' => "TWO", +); +$doc3 = array( + '_id' => new MongoId('4cb4ab6d7addf98506010002'), // same _id as above + 'id' => 3, + 'desc' => "THREE", +); +$doc4 = array( + '_id' => new MongoId('4cb4ab6d7addf98506010004'), + 'id' => 4, + 'desc' => "FOUR", +); + +$c = $db->selectCollection('c'); +$c->batchInsert( + array($doc1, $doc2, $doc3, $doc4), + array('continueOnError' => true) +); + +$docs = $c->find(); +foreach ($docs as $doc) { + var_dump($doc['desc']); +} +?> +]]> + </programlisting> + &example.outputs.similar; + <screen> +<![CDATA[ +string(3) "ONE" +string(3) "TWO" +string(4) "FOUR" +]]> + </screen> + </example> </refsect1> <refsect1 role="seealso">

« previous php.doc.cvs (#9841) next »