Answer the question
In order to leave comments, you need to log in
How to update a record in mongodb?
Hey!
Problem:
a thick object is transferred to the php file by ajax, I need to add this object by id to mongo, and the id also comes from ajax
, here is the code:
$mongo = new MongoClient();
$editor = $db->editor;
$editor->update(
array( '_id' => $_GET['id'] ),
array( '$set' => json_decode($_POST['data']) )
);
Answer the question
In order to leave comments, you need to log in
I will assume that you need to pass as _id not a text, but a MongoId($_GET['id']) object
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question