To insert a document into MongoDB, insert() method is used.įollowing is the code snippet to insert a document −Įcho "Collection selected succsessfully" $collection = $db->createCollection("mycol") When the program is executed, it will produce the following result −įollowing is the code snippet to create a collection − To make a connection, you need to specify the database name, if the database doesn't exist then MongoDB creates it automatically.įollowing is the code snippet to connect to the database − Now unzip the archive and put php_mongo.dll in your PHP extension directory ("ext" by default) and add the following line to your php.ini file − ![]() Make sure to download the latest release of it. Download the driver from the url Download PHP Driver. ![]() To use MongoDB with PHP, you need to use MongoDB PHP driver.
0 Comments
Leave a Reply. |