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

时间:2011-12-12 11:08:04

标签: symfony doctrine-orm entities

这是我的配置文件:

# 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)。

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

1 个答案:

答案 0 :(得分:2)

我已经测试了这个命令来为我的应用创建实体,它似乎有效:

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