不同管理者之间的实体协会 [英] Entities associations across different managers
问题描述
我有一个关于教义和Symfony 2的小问题:
I have a small question about doctrine and Symfony 2:
是否可以在由两个不同实体管理器管理的两个实体之间声明一个关系(OneToMany) (和两个不同的DB连接)?
Is it possible to declare a relation (OneToMany) between two entities which are managed by two different entity managers (and two different DB connections) ?
更准确地说,我有两个软件包:
To be more precise, I have two bundles :
-
FpnABundle
- >映射为A_database
(和A_entitymanager
-
FpnBBundle
- >用B_database
(和B_entitymanager
)
FpnABundle
-> Mapped withA_database
(andA_entitymanager
)FpnBBundle
-> Mapped withB_database
(andB_entitymanager
)
我需要定义 FpnABundle:User
和 FpnBBundle:Post
如果我尝试这样做,当我执行DB模式更新时,我有以下错误:
If I try to do that, when I perform a DB schema update, I have the following error :
The class 'Fpn\ABundle\Entity\User' was not found in the chain configured namespaces Fpn\BBundle\Entity
感谢您的帮助!
推荐答案
基本上,答案是否定的。
Basically, the answer is no.
你可能需要这么做: http://symfony.com/doc/current/cookbook/doctrine/resolve_target_entity.html
即使这样,只有在两个数据库位于同一台服务器上的情况下才会起作用。在某些时候,您可能需要将表名称添加到表名中。有点痛苦。
Even with this it will only work if the two databases are on the same server. And at some point you will probably need to add the schema name to the the table name. Somewhat painful.
这篇关于不同管理者之间的实体协会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!