Answer the question
In order to leave comments, you need to log in
How to save json to mongoDB using PHP?
Hello!
i get json string and i want to store it in mongo using php like this:
$mongo = new MongoClient();
$db = $mongo->database;
// access collection
$collection = $db->collection;
$collection->insert($_POST['data']);
Answer the question
In order to leave comments, you need to log in
$m = new MongoClient();
$collection = $m->selectCollection('test', 'phpmanual');
// If an array literal is used, there is no way to access the generated _id
$collection->insert(array('x' => 1));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question