php 使用 PDO 驱动程序连接到 mongodb
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8255440/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Connecting to mongodb using PDO driver
提问by user1063715
Will I be able to connect to this database using php's php_mongo.dll driver?
我可以使用 php 的 php_mongo.dll 驱动程序连接到这个数据库吗?
If so, could you please provide some sample code as I was not able to get it in any forum?
如果是这样,您能否提供一些示例代码,因为我无法在任何论坛中获得它?
回答by Gates VP
MongoDB requires its own driver.
MongoDB 需要自己的驱动程序。
In your case, the PHP driver is located here: http://php.net/manual/en/book.mongo.php
在您的情况下,PHP 驱动程序位于此处:http: //php.net/manual/en/book.mongo.php
The instructions for installing it are on that page. There is also some sample code.
安装它的说明在那个页面上。还有一些示例代码。
回答by Paulo Luvisoto
I think that PDO is only for relational databases. There's no PDO driver for mongodb.
我认为 PDO 仅适用于关系数据库。mongodb 没有 PDO 驱动程序。
回答by fojt
There is list of databases which you can use with PDO driver: http://php.net/manual/en/pdo.drivers.phpMongoDb is not among them.
有可以与 PDO 驱动程序一起使用的数据库列表:http: //php.net/manual/en/pdo.drivers.php MongoDb 不在其中。
回答by Star
You can use the PHP PDO OBDC library, if you install MongoDB BI Connector and MongoDB ODBC Driver for BI Connector.
如果您为 BI 连接器安装了 MongoDB BI 连接器和 MongoDB ODBC 驱动程序,则可以使用 PHP PDO OBDC 库。
I haven't tried it, but I'm about to - keep you posted.
我还没有尝试过,但我即将 - 通知你。
https://www.mongodb.com/download-center/bi-connectorhttps://docs.mongodb.com/bi-connector/master/reference/odbc-driver/
https://www.mongodb.com/download-center/bi-connector https://docs.mongodb.com/bi-connector/master/reference/odbc-driver/