gpt4 book ai didi

交响乐2 : Add another namespace to Entity namespaces

转载 作者:行者123 更新时间:2023-12-02 10:53:09 25 4
gpt4 key购买 nike

在我的 symfony2 应用程序中,我有两个数据库连接,我想将实体类分开,因此在一个包中拥有一组实体类,在另一个包中拥有另一组实体类。但是,当尝试调用我的包时,由于某种原因,它没有注册为实体命名空间,错误如下:

Unknown Entity namespace alias 'AcmeStaffBundle'.
500 Internal Server Error - ORMException

我已经查找了它设置实体 namespace 的位置,并且发现它位于缓存文件中

$e = new \Doctrine\ORM\Configuration();
$e->setEntityNamespaces(array('AcmeStoreBundle' => 'Acme\\StoreBundle\\Entity'));

如何将其添加到数组中?

新编辑:

我的 config.yml 如下,这应该有助于澄清问题:

orm:
entity_managers:
default:
connection: default
mappings:
AcmeStoreBundle: ~
Foo:
connection: Foo
mappings:
AcmeFooBundle: ~

提前致谢

最佳答案

我在尝试使用生成的 CRUD 表单时遇到了这个确切的问题。最终解决问题的方法是将首选实体管理器的名称作为参数添加到 getEntityManager() 中,如下所示:

$em = $this->getDoctrine()->getEntityManager('Foo');

关于交响乐2 : Add another namespace to Entity namespaces,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8564871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com