Symfony 2:从多个数据库生成实体

这是我的配置文件:

# Doctrine Configuration
doctrine:
    dbal:
        default_connection: flux
        connections:
            flux:
                driver:   %db_flux_driver%
                host:     %db_flux_host%
                port:     %db_flux_port%
                dbname:   %db_flux_name%
                user:     %db_flux_user%
                password: %db_flux_password%
                charset:  UTF8
            commun:
                driver:   %db_commun_driver%
                host:     %db_commun_host%
                port:     %db_commun_port%
                dbname:   %db_commun_name%
                user:     %db_commun_user%
                password: %db_commun_password%
                charset:  UTF8
    orm:
        default_entity_manager: default
        entity_managers:
            default:
                connection: flux
                mappings:
                    CreatisSaisieBundle: ~
            commun:
                connection: commun
                mappings:
                    CreatisSaisieBundle: ~

如你所见,我正在使用2个连接.

我一直在使用app / console doctrine:mapping:convert xml命令行来生成我的orm xml文件但是只从我的默认连接生成实体(flux).

是否有一个选项允许从特定连接或所有连接生成实体?

最佳答案 我测试了这个命令为我的应用程序创建实体,它似乎工作:

php app/console doctrine:mapping:convert --em="ENTITY_MANAGER" --from-database yml ./src/NAMESPACE/NAMEBundle/Resources/config/doctrine/metadata/orm
点赞