Symfony 2 : Generate entities from multiple databases

百般思念 提交于 2019-12-07 11:05:21

问题


Here is my config file:

# 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: ~

As you can see I'm using 2 connections.

I've been using the app/console doctrine:mapping:convert xml command line to generate my orm xml files but that only generated the entities from my default connection (flux).

Is there an option that allows to generate entities from a specific connection, or from all of them?


回答1:


I've test this command to create entity for my app, it seems to work:

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


来源:https://stackoverflow.com/questions/8473366/symfony-2-generate-entities-from-multiple-databases

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!