mongodb cakephp驱动程序安装

时间:2011-11-21 05:05:22

标签: cakephp mongodb installation

我正在尝试让mongodb与cakephp合作。我不确定在哪里放置ichikaway的mongodb驱动程序cakephp以及在哪里添加数据库连接。

我的目录结构是,在c:/websites/下,我有cakephp文件夹和我的项目merry_flowers文件夹。

我已经浏览了ichikaway的github和mark story的网站。

如果我将mongodb驱动程序放在\ cakephp \ app \ plugins和\ cakephp \ app \ config \ database.php中的数据库连接中 我收到以下错误:

fatal error 256: ConnectionManager::loadDataSource - Unable to import DataSource class mongodb.mongodbSource [CORE\cake\libs\model\connection_manager.php, line 185]Code | Context
        if (!App::import('Datasource', $class, !is_null($conn['plugin']))) {
            trigger_error(sprintf(__('ConnectionManager::loadDataSource - Unable to import DataSource class %s', true), $class), E_USER_ERROR);$connName    =   "mongo"
$_this  =   ConnectionManager
ConnectionManager::$config = DATABASE_CONFIG object
ConnectionManager::$_dataSources = array
ConnectionManager::$_connectionsEnum = array
$conn   =   array(
    "plugin" => "mongodb",
    "classname" => "mongodbSource",
    "parent" => array(
    "filename" => "dbo_source",
    "classname" => "DboSource",
    "parent" => null,
    "plugin" => null
),
    "filename" => "dbo\mongodb_source"
)
$class  =   "mongodb.mongodbSource"ConnectionManager::loadDataSource() - CORE\cake\libs\model\connection_manager.php, line 185
ConnectionManager::getDataSource() - CORE\cake\libs\model\connection_manager.php, line 109
Model::setDataSource() - CORE\cake\libs\model\model.php, line 2836
Model::__construct() - CORE\cake\libs\model\model.php, line 469
ClassRegistry::init() - CORE\cake\libs\class_registry.php, line 142
Controller::loadModel() - CORE\cake\libs\controller\controller.php, line 637
Controller::constructClasses() - CORE\cake\libs\controller\controller.php, line 493
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 186
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 171
[main] - APP\webroot\index.php, line 87

如果我将mongodb驱动程序放在\ merry_flowers \ plugins中并将数据库连接添加到\ merry_flowers \ config \ database.php,我收到以下错误:

  connecting to localhost:27017 failed: Unknown error APP\plugins\mongodb\models\datasources\mongodb_source.php, line 201
谢谢。

1 个答案:

答案 0 :(得分:2)

使用哪个插件文件夹无关紧要。两者都具有相同的功能。两者都包含在您的组织中。

您是否也设置了mysql数据库?如果是这样,可能没有双重安装的文档。如果您只有一个数据库,则应在cakephp/app/config/database.php

中进行配置