note 105467 added to mongocollection.insert

From: Date: Sat, 20 Aug 2011 07:15:22 +0000
Subject: note 105467 added to mongocollection.insert
Groups: php.notes 
Request: Send a blank email to php-notes+get-182597@lists.php.net to get a copy of this message
There seems to be some odd behavior when writing a query then reading it back in very quickly. I found it useful to ensure "safe" was set to true in order to stop random "'MongoCursorException' with message 'couldn't send query: Broken pipe'" messages all the time. This is only in a development environment, so i'm not sure if it relates to our hardware, but safe inserts fixed the issue 100%. Not even sure if it's the correct approach but it worked. Note that the error doesn't seem to appear with small queries like below, but larger data it does. Example: // connect $m = new Mongo(); // select a database $db = $m->comedy; // select a collection (analogous to a relational database's table) $collection = $db->cartoons; // add a record $obj = array( "title" => "Calvin and Hobbes", "author" => "Bill Watterson" ); $collection->insert($obj, array('safe'=>true)); // find everything in the collection $cursor = $collection->find(array('author' => 'Bill Watterson')); // iterate through the results foreach ($cursor as $obj) { echo json_encode($obj) . "<br />"; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 203.45.149.26 ---- Manual Page -- http://www.php.net/manual/en/mongocollection.insert.php Edit -- https://master.php.net/note/edit/105467 Del: integrated -- https://master.php.net/note/delete/105467/integrated Del: useless -- https://master.php.net/note/delete/105467/useless Del: bad code -- https://master.php.net/note/delete/105467/bad+code Del: spam -- https://master.php.net/note/delete/105467/spam Del: non-english -- https://master.php.net/note/delete/105467/non-english Del: in docs -- https://master.php.net/note/delete/105467/in+docs Del: other reasons-- https://master.php.net/note/delete/105467 Reject -- https://master.php.net/note/reject/105467 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182597) next »