0

I have successfully added mongodb to my server and I am able to work from the mongo shell no problem, I can also connect to the database from php just fine. I have also downloaded and semi successfully installed the plugin for mongodb and cakephp. However I am now stuck with cakephp not able to connect to the database. I have followed both ichikawa's github and mark story's web page on the subject but neither has helped get over this hump. Does anyone have any suggestions on what I should try to get this hooked up and running?

4

2 回答 2

0

我遇到了这个问题,一个朋友找到了一个链接,告诉我们替换 /app/Plugin/Mongodb/Model/Datasource/MongodbSource.php 的第 185 行。这是旧线和新线。

// $this->connection = new Mongo($host, array("persist" => $this->config['persistent']));
$this->connection = new Mongo($host);

我可以尝试找到 URL,但解决方案在上面。

于 2012-12-15T18:55:07.990 回答
0

因为你的服务器使用的是 mongodb driver 1.x。让我们修复:

在 app/Plugin/Monggodb/MongodbSource.php(第 197 行)中,找到:

else if ($this->_driverVersion >= '1.3.0') {
                $this->connection = new $class($host);  // mongodb 2.x             
            } 

代替:

else if ($this->_driverVersion >= '1.3.0' && $this->_driverVersion < '2.0') {
$this->connection = new $class("mongodb://loginID:password@IP"); // mongodb 1.5.6, loginID: your mongodb user login;     
}  

使用上面的代码,您更改了连接字符串,因为连接字符串在 mongo 2.x 和 1.x 之间有所不同

选对了就投票吧!乐趣!

于 2014-10-08T07:10:46.163 回答