Y
Y
yaNitik2015-08-23 17:03:45
PHP
yaNitik, 2015-08-23 17:03:45

Working from PHP with MongoDB 3.0 could be easier?

In previous versions of the php driver, it was possible to work with mongo (Also previous versions) easier and more convenient.
Now we have to do a lot of additional actions and write additional classes.
Among the new driver classes, is there one that simplifies everything?
For example,
/*Let's connect to the database*/
NeizvestniyClass("db.products.insert( { item: "card", qty: 15 } )")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dexmaster, 2015-08-23
@yaNitik

MongoDB::execute won't work with MongoDB 3.0+ (as they deprecated eval)
All you need to do is write functions in PHP format.
You can even pass the data to JSON and pull it out for PHP /json_decode/.

$data = json_decode( '{ "item": "card", "qty": 15 }' ); // $_POST['product']
$mongoDB->products->insert( $data );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question