As we know, there is a new PHP 7 MongoDB driver, and lots of classes and functions are replaced by new ones. So can anyone give me a quick example of how to use MongoDB with PHP7 properly?
Asked
Active
Viewed 1,592 times
3
-
http://stackoverflow.com/questions/34486808/installing-the-php-7-mongodb-client-driver – JYoThI May 21 '16 at 05:08
-
Welcome to stackoverflow, but the question you ask is not suitable in stackoverflow, please take look at here. http://stackoverflow.com/help – Fil May 21 '16 at 05:09
-
Now it's more on-topic! :) – Will May 21 '16 at 05:26
1 Answers
-1
1) I advise you to use the PHP Library : https://github.com/mongodb/mongo-php-library
2) Here is some code I use to connect to DB / collection
$client = new MongoDB\Client("mongodb://USER:PASSWORD@localhost:27017/BaseName");
$collection = $client->BaseName->CollectionName;
3) Example of FindOne query :
$document = $collection->findOne(
['SomeField' => ''$var'']
);
4) Check out the docs of the library here , they give a few examples. https://github.com/mongodb/mongo-php-library

Chuck
- 98
- 2
- 10