Reputation: 1014
In my Symfony2 browsergame I have an user entity using the Doctrine 2 ORM. The game has two instances, classic and speed, which are mainly independent from each other and are using both its own databases (same structure). The only problem is that users are able to connect their accounts, so some basic user informations of the connected account shall be shown. For that I have a classic_id and speed_id as properties which connect to another user entity. But that would be a a cross database join which is not possible in Doctrine 2 as far as I found out. I also found that it is possible to have multiple entity managers with their own connections, but I think they can only be applied to complete bundles, right?
So here I need some workaround for that problem, what is the easiest way to do that?
Upvotes: 1
Views: 3472
Reputation: 11364
Actually there is possibility to do cross db joins, but it's rather trick than a feature and I do not recommend use it.
To separate entities from one bundle between different entity managers you can use "dir" attribute which points to managed entities. For example:
doctrine:
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
mappings:
AppBundle:
dir: Path/To/EntityFolder1
anotherone:
connection: anotherconnection
mappings:
AppBundle:
dir: Path/To/EntityFolder2
There is also poor documented "prefix" option, but I didn't figure out what it is yet (you can experiment by yourself:))
Greetings!
Upvotes: 2