Skip to main content
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Using Relationships with Multiple Entity Managers

I am wondering if it is possible to create a relationship between two entities that reside in separate databases.

For example if we took the solution found here http://symfony.com/doc/current/cookbook/doctrine/multiple_entity_managers.html and created a one to many relationship with Users in the customer database to Posts in the default database.

Is this something that is supported by Symfony2 and Doctrine?

Answer*

Draft saved
Draft discarded

Required fields are marked with *

Cancel
11
  • 12
    if your RDBMS supports cross-database operations on a single host, you can just use a single EntityManager and reference the other table. Excellent advice. Thanks!
    noisebleed
    –  noisebleed
    2012-12-24 15:17:16 +00:00
    Commented Dec 24, 2012 at 15:17
  • 4
    Found out that Doctrine only detects schema changes in the default_connection tables, when using only one entity manager and multiple databases. Any idea to workaround this?
    noisebleed
    –  noisebleed
    2012-12-25 23:26:49 +00:00
    Commented Dec 25, 2012 at 23:26
  • 1
    @noisebleed from the docs: $ php app/console doctrine:schema:update --force --em=customer. read more here: symfony.com/doc/current/cookbook/doctrine/…
    xfscrypt
    –  xfscrypt
    2015-08-10 13:57:07 +00:00
    Commented Aug 10, 2015 at 13:57
  • 2
    @DonCallisto there is no newer approach, as far as I know.
    Ocramius
    –  Ocramius
    2016-04-12 11:48:49 +00:00
    Commented Apr 12, 2016 at 11:48
  • 1
    Yes, the "Table" annotation has a "schema" attribute since a few minor version of the ORM
    Ocramius
    –  Ocramius
    2016-04-30 03:24:16 +00:00
    Commented Apr 30, 2016 at 3:24

lang-php
Morty Proxy This is a proxified and sanitized view of the page, visit original site.