不同管理者之间的实体协会 [英] Entities associations across different managers

查看:160
本文介绍了不同管理者之间的实体协会的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于教义和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 with A_database (and A_entitymanager)
  • FpnBBundle -> Mapped with B_database (and B_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屋!

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