I have an entity A with a ManyToOne relationship with B, but A and B do not belong to the same DB schema.
Entity 'A' belongs to the MyBundle package, and entity 'B' belongs to the MyOtherBundle package.
The official documentation explains how to work with different connections: several schemes = several object managers. But in my case, I would like to join both objects.
Performing:
$this->objEm->getRepository('MyBundle:MyEntity')->find($id);
or
$this->objEm->getRepository('MyBundle:MyEntity')->getMyResult($id);
I only call one of my repositories, and I think it cannot get another, because in my config.yml I can only select one connection.
doctrine: dbal: connections: connection1: driver: "%database_driver%" host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_schema1_user%" password: "%database_schema1_password%" service: "%database_service%" charset: "Windows-1252" connection2: driver: "%database_driver%" host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_schema2_user%" password: "%database_schema2_password%" service: "%database_service%" charset: "Windows-1252" orm: entity_managers: em1: connection: connection1 mappings: MyBundle: ~ MyOtherBundle: ~ em2: connection: connection2 mappings: MyOtherBundle: ~
Result: Oops, it looks like something went wrong.
1 / 1ReflectionException: class FQCN \ Of \ MyBundle \ Entity \ B does not exist ...
"I know that there is no dude, I want you to look at a good place now: for example, in FQCN \ Of \ MyOtherBundle \ Entity \ B"
How can I force the path to my entity "B"?
user1913526
source share