本文介绍了与symfony中的原则的多重联系2.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



首先,我只使用一个数据库,然后我需要添加另一个数据库



这是以前:

 #教条配置
原则:
dbal:
default_connection:extranet
连接:
extranet:
驱动程序:pdo_mysql
主机:%db_extranet_host%
端口:%db_extranet_port%
dbname:%db_extranet_name%
用户:%db_extranet_user%
密码:%db_extranet_password%
charset:UTF8
orm:
auto_generate_proxy_classes:%kernel.debug%
entity_managers:
extranet:
naming_strategy:doctrine.orm.naming_strategy.underscore
auto_mapping:true

,并且正常工作



爬行数据库:

 #Doctrine Configuration 
doctrine:
dbal:
default_connection:extranet
连接:
extranet:
驱动程序:pdo_mysql
主机:%db_extranet_host%
端口:%db_extranet_port%
dbname:%db_extranet_name %
user:%db_extranet_user%
password:%db_extranet_password%
charset:UTF8
crawl:
驱动程序:pdo_mysql
主机: %db_crawl_host%
port:%db_crawl_port%
dbname:%db_crawl_name%
user:%db_crawl_user%
password:%db_crawl_password%
字符集:UTF8
orm:
auto_generate_proxy_classes:%kernel.debug%
default_entity_manager:extranet
entity_managers:
extranet:
connection: EXT ranet
naming_strategy:doctrine.orm.naming_strategy.underscore
映射:
AppBundle:〜
crawl:
连接:爬行
naming_strategy:doctrine.orm。 naming_strategy.underscore
mappings:
DbBccCrawlBundle:〜

我摆脱了auto_mapping&添加了一些东西



但是,现在我失去了连接到extranet(例如用户不能登录)



任何想法? (如果你读了这么远,谢谢))



编辑



我尝试使用相同的语法:

  orm:
#auto_generate_proxy_classes:%kernel.debug%
default_entity_manager:extranet
#auto_mapping:true
映射:
AppBundle:
类型:注释
dir:'%kernel.root_dir%/ .. / src / AppBundle / Entity'
前缀:AppBundle\Entity
别名:应用程序
DbBccCrawlBundle:
类型:注释
dir:'%kernel.root_dir%/ .. / src / DbBccCrawlBundle / Entity'
前缀:DbBccCrawlBundle\Entity
别名:抓取

仍然无效....



编辑2

  orm:
auto_generate_proxy_classes:%kernel.debug%
default_entity_manager:extranet
entity_managers:
auto_mapping:true
extranet:
连接:extranet
naming_strategy:doctrine.orm.naming_strategy.underscore
映射:
AppBundle:
类型:注释
#dir:'%kernel.root_dir%/ .. / src / AppBundle / Entity'
#前缀:AppBundle\Entity
别名:App
crawl:
连接:爬行
naming_strategy:doctrine.orm.naming_strategy.underscore
映射:
DbBccCrawlBundle:
类型:注释
#dir:'%kernel.root_dir%/ .. / src / D bBccCrawlBundle / Entity'
#前缀:DbBccCrawlBundle\Entity
别名:Crawl

不工作

解决方案

我不知道为什么/如何工作



这里是代码:

  orm:
auto_generate_proxy_classes:%kernel.debug%
entity_managers :
extranet:
naming_strategy:doctrine.orm.naming_strategy.underscore
auto_mapping:true
crawl:
naming_strategy:doctrine.orm.naming_strategy.underscore
连接:抓取
映射:
DbBccCrawlBundle:〜

事情是我尝试一开始,它失败了(X类没有找到...)



如果有人有了探索,我会很乐意阅读它



无论如何



这是问题的第二部分,这里是begening:
的多重连接时,在链配置的命名空间中找不到类X


So I'm trying to do a multiple connection with doctrine in my symfony project.

First, I was only using one database, then I needed to add another.

this was before :

# Doctrine Configuration
doctrine:
  dbal:
    default_connection: extranet
    connections:
        extranet:
            driver:   pdo_mysql
            host:     "%db_extranet_host%"
            port:     "%db_extranet_port%"
            dbname:   "%db_extranet_name%"
            user:     "%db_extranet_user%"
            password: "%db_extranet_password%"
            charset:  UTF8
orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    entity_managers:
        extranet:
            naming_strategy: doctrine.orm.naming_strategy.underscore
            auto_mapping: true

and it was working fine

THEN I added the "crawl" database :

# Doctrine Configuration
doctrine:
  dbal:
    default_connection: extranet
    connections:
        extranet:
            driver:   pdo_mysql
            host:     "%db_extranet_host%"
            port:     "%db_extranet_port%"
            dbname:   "%db_extranet_name%"
            user:     "%db_extranet_user%"
            password: "%db_extranet_password%"
            charset:  UTF8
        crawl:
            driver:   pdo_mysql
            host:     "%db_crawl_host%"
            port:     "%db_crawl_port%"
            dbname:   "%db_crawl_name%"
            user:     "%db_crawl_user%"
            password: "%db_crawl_password%"
            charset:  UTF8
orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    default_entity_manager: extranet
    entity_managers:
        extranet:
            connection: extranet
            naming_strategy: doctrine.orm.naming_strategy.underscore
            mappings:
                AppBundle: ~
        crawl:
            connection: crawl
            naming_strategy: doctrine.orm.naming_strategy.underscore
            mappings:
                DbBccCrawlBundle: ~

I got rid of the auto_mapping & added few things

BUT, now I lost connection to extranet (users can't loggin anymore for example)

Any ideas? (and thanks if you read that far ;) )

EDIT

following http://symfony.com/doc/2.3/reference/configuration/doctrine.html#mapping-entities-outside-of-a-bundle I tried to have the same syntax :

orm:
    # auto_generate_proxy_classes: "%kernel.debug%"
    default_entity_manager: extranet
    # auto_mapping: true
    mappings:
        AppBundle:
            type: annotation
            dir: '%kernel.root_dir%/../src/AppBundle/Entity'
            prefix: AppBundle\Entity
            alias: App
        DbBccCrawlBundle:
            type: annotation
            dir: '%kernel.root_dir%/../src/DbBccCrawlBundle/Entity'
            prefix: DbBccCrawlBundle\Entity
            alias: Crawl

still doesn't work....

EDIT 2

orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    default_entity_manager: extranet
    entity_managers:
        auto_mapping: true
        extranet:
            connection: extranet
            naming_strategy: doctrine.orm.naming_strategy.underscore
            mappings:
                AppBundle:
                    type:   annotation
                    # dir:    '%kernel.root_dir%/../src/AppBundle/Entity'
                    # prefix: AppBundle\Entity
                    alias:  App
        crawl:
            connection: crawl
            naming_strategy: doctrine.orm.naming_strategy.underscore
            mappings:
                DbBccCrawlBundle:
                    type:   annotation
                    # dir:    '%kernel.root_dir%/../src/DbBccCrawlBundle/Entity'
                    # prefix: DbBccCrawlBundle\Entity
                    alias:  Crawl

not working either

解决方案

I donno why/how but it works

here's the code :

orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    entity_managers:
        extranet:
            naming_strategy: doctrine.orm.naming_strategy.underscore
            auto_mapping: true
        crawl:
            naming_strategy: doctrine.orm.naming_strategy.underscore
            connection: crawl
            mappings:
                DbBccCrawlBundle: ~

the thing is that I tried that at the start and it failed (the class X not found in...)

If anyone has an explenation, I'll be more than happy to read it.

Thanks anyway

This was the 2nd part of the question, here's the begening :The class 'X' was not found in the chain configured namespaces ... when I try a multiple connection with doctrine

这篇关于与symfony中的原则的多重联系2.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 16:13