Symfony 2:从多个数据库生成实体 [英] Symfony 2 : Generate entities from multiple databases

查看:148
本文介绍了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个连接。

As you can see I'm using 2 connections.

我一直在使用app / console原则:mapping:convert xml命令行生成我的orm xml文件,但是只能从我的默认连接生成实体)

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?

推荐答案

我已经测试了这个命令为我的应用程序创建实体,似乎工作:

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

这篇关于Symfony 2:从多个数据库生成实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆