Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to MongoDB using PDO driver

Will I be able to connect to this database using PHP's php_mongo.dll driver?

If so, could you please provide some sample code?

like image 900
user1063715 Avatar asked Nov 24 '11 10:11

user1063715


People also ask

Does PDO support MongoDB?

PDO is a universal database connection command in PHP, it support 12 different database type e.g MySQL, MongoDB, NoSQL.

Can we connect PHP with MongoDB?

You can add the driver to your application to work with MongoDB in PHP. The MongoDB PHP Driver consists of the two following components: The extension , which provides a low-level API and mainly serves to integrate libmongoc and libbson with PHP.

What is a MongoDB driver?

The official MongoDB Node. js driver allows Node. js applications to connect to MongoDB and work with data. The driver features an asynchronous API which allows you to interact with MongoDB using Promises or via traditional callbacks.


2 Answers

MongoDB requires its own driver.

In your case, the PHP driver is located here: http://php.net/manual/en/book.mongo.php

The instructions for installing it are on that page. There is also some sample code.

like image 131
Gates VP Avatar answered Sep 18 '22 05:09

Gates VP


I think that PDO is only for relational databases. There's no PDO driver for MongoDB.

like image 39
Paulo Luvisoto Avatar answered Sep 22 '22 05:09

Paulo Luvisoto