Download the PHP package thomas-squall/php7-mongo-driver without Composer
On this page you can find all versions of the php package thomas-squall/php7-mongo-driver. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thomas-squall/php7-mongo-driver
More information about thomas-squall/php7-mongo-driver
Files in thomas-squall/php7-mongo-driver
Package php7-mongo-driver
Short Description PHP7 Driver for MongoDb
License MIT
Informations about the package php7-mongo-driver
MongoDriver for PHP7
With the advent of PHP7 the old mongodb driver is no more supported.
The new driver available is a little bit low-level compared to the previous one so it can be a bit complicated to work with.
This is what this library was conceived for.
!!! FOR DETAILED GUIDELINES CONSULT THE WIKI AT: https://github.com/ThomasSquall/PHP7MongoDriver/wiki
Installation
Using composer is quite simple, just run the following command:
Prerequisites
Before using this library you should make sure to have installed PHP7.0 or major and MongoDb driver from pecl.
For those using a Linux distribution (make sure to have pecl installed) just run:
After that you should put the following string
Inside your php.ini
Usage
At first you need to define a connection string.
The format for connection strings is:
For more information see the link: https://docs.mongodb.com/manual/reference/connection-string/
Once defined you need to instantiate a new Adapter:
At this point you want to select a Database where do your query:
NOTE: you could select a database directly on the constructor passing the database name as the 2nd parameter.
Find
Once selected the database we can simply query for the collection we want:
You can also filter your query:
Insert
If you want to insert an item you have simply to pass an array or an object to the insert function specifying the collection:
Hope you guys find this library useful.
Please share it and give me a feedback :)
Thomas