Q
Q
Qubert2014-07-31 13:28:58
PHP
Qubert, 2014-07-31 13:28:58

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']) )
      );

nothing is entered =( what could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Kheben, 2014-07-31
@zBit

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 question

Ask a Question

731 491 924 answers to any question