Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Blocker
-
Resolution: Can't Fix
-
Affects Version/s: Git Master
-
Fix Version/s: None
-
Component/s: ORM
-
Security Level: All
-
Labels:None
-
Environment:Symfony2 with Doctrine2 using MySQL
Description
Hello,
I'm working on a Symfony based CMS for a game server. The game server use two databases (the `auth` database and `characters` database) and i've created a new one for the CMS named `site`.
Currently my News entity must have a relation with the Account entity but the News entity come from the Site EntityManager (who manage the `site` database) and the Account entity come from the Auth EntityManager (who manage the `auth` database).
So, when I prompt the command "php app/console doctrine:schema:update --em="site" --force" I got the error "Class Eluna\MemberBundle\Entity\Account is not a valid entity or mapped super class." But if I join an entity who is in the same EntityManager it work perfectly.
My code :
/**
* @var object $author
*
* @ORM\ManyToOne(targetEntity="Eluna\MemberBundle\Entity\Account")
* @ORM\JoinColumn(name="author", referencedColumnName="id")
*/
private $author;
Unless the entities are in the same database server (MySQL) but just in different databses you can use the syntax "database.table" in the @Table. Otherwise there is no nice solution, you have to save the foreign key manually in an integer column and maybe use an event listener to fetch a proxy of the related object. But that has to be coded manually.