从配置文件中为symfony2选择mongodb数据库

时间:2014-03-27 13:05:39

标签: php mongodb symfony

我正在尝试使用symfony2连接到两个mongodb数据库,当我尝试使用一个数据库时它运行良好,但有两个我有错误,这是我的config.yml文件:

doctrine_mongodb:
connections:
    statistiques:
        server: mongodb://user:pass@localhost:27017/statistiques
        options: 
            db: statistiques

    archive_prod:
        server: mongodb://user:pass@localhost:27017/archive_prod
        options: 
            db: archive_prod

document_managers:
    statistiques:
        auto_mapping: true
        connection: statistiques

    archive_prod:
        auto_mapping: true
        connection: archive_prod

在错误中我有这个: 无法连接到:localhost:27017:使用用户名'user'在数据库'default'上进行身份验证失败:auth failed

即使我没有选择任何名为'default'的数据库 我可以使用以下命令设置默认数据库:default_database:statistiques 但我需要使用两个数据库

相关问题