Two databases and various entities

How can I associate two entities, each in a different database. I have created two entity manager one for each database, default and customer_1.

Upvotes: 0

Views: 52

Answers (1)

Mark
Mark

Reputation: 5767

You cannot associate entities in different databases, at least not in the latest Doctrine version.

Moreover this is not advisable as the underlying database server (ie. MySQL) will not be able to guarantee data integrity across independent databases. Foreign keys for example do not allow you to reference keys outside the parent database.

The multiple entity managers as envisioned by Symfony here http://symfony.com/doc/current/cookbook/doctrine/multiple_entity_managers.html are meant only for accessing different bundle sets in the same app. If you want to associate your entities you'll have to use one database.

Upvotes: 1

Related Questions