I have one collection test_posts in which there are certain records. There is field called 'is_published' which has either 1 or 0 value. Based on which I am showing the content on end user side. I can show the content but for update there is some change in query as per MongoDB.
Here is sample code:
$newdata = array('$set' => array("is_published" => $_REQUEST['is_published'] ));
$c->update(array("id" => "1"), $newdata);
I write this code for updating the only particular record.Its similar to MySql query like:
UPDATE test_posts SET is_published = '" . $_REQUEST['is_published'] ."' WHERE id= '" . $_REQUEST['id'] ."'";
Is my MongoDb query same as of MySql ? Please suggest any changes if required.
Please suggest how to update the record for particular request data in MongoDB using MongoClient.
hope this will help you and note the update query will act as insert query if update field is not found