ReflectionException is thrown when mapping entities in Doctrine from different databases

前端 未结 1 774

I\'m trying to use Doctrine 2 in a ZF2 application which contains two modules, each with its own database. I need to use cross-database joins so that I can associate entitie

相关标签:
1条回答
  • 2021-01-16 23:58

    I managed to fix it. In my Server\Entity\Server, I had these getter/setter functions for adding/removing websites:

    public function setWebsite(Website $website) 
    {
       $this->websites->add($website);    
    }
    
    public function removeWebsite(Website $website)
    {
       $this->websites->removeElement($website);
    }
    

    But you need to specify the full namespace as the argument:

    public function setWebsite(\Client\Entity\Website $website) { ... }
    

    Such a stupid mistake! I found the issue because I trawled through every file in the stack-trace and got to the point where it was attempting to save every method/argument in my Entity class to a proxy file (line 223ish in Doctrine/ORM/Proxy/ProxyFactory.php).

    0 讨论(0)
提交回复
热议问题