note 114792 added to mongocollection.findandmodify
| From: | Barmy | Date: | Mon, 07 Apr 2014 16:24:37 +0000 |
| Subject: | note 114792 added to mongocollection.findandmodify | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199208@lists.php.net to get a copy of this message | ||
There is an easy way to find and replace by _id :
<?php
// ...
// Selecting unparsed lines
$cursor = $collection->find(array("mydata_isParsed" => array('$ne' =>
1)));
// Doing our stuff
foreach($cursor as $document) {
// should always be ok, just in case
if (!isset($document["mydata_isParsed"])) {
// ... do some stuff
// flag as parsed and update line
$document["mydata_isParsed"] = 1;
$idField = '$id';
$collection->findAndModify(array("_id" => new
MongoId($document["_id"]->$idField)), $document);
}
}
----
Server IP: 195.221.21.36
Probable Submitter: 82.120.196.131
----
Manual Page -- http://php.net/manual/en/mongocollection.findandmodify.php
Edit -- https://master.php.net/note/edit/114792
Del: integrated -- https://master.php.net/note/delete/114792/integrated
Del: useless -- https://master.php.net/note/delete/114792/useless
Del: bad code -- https://master.php.net/note/delete/114792/bad+code
Del: spam -- https://master.php.net/note/delete/114792/spam
Del: non-english -- https://master.php.net/note/delete/114792/non-english
Del: in docs -- https://master.php.net/note/delete/114792/in+docs
Del: other reasons-- https://master.php.net/note/delete/114792
Reject -- https://master.php.net/note/reject/114792
Search -- https://master.php.net/manage/user-notes.php