问题描述
我正在将 Doctrine2 与 codeigniter 一起使用.我的项目已创建,但我必须在数据库表中添加前缀.在codeigniter中,我已使用dbprefix $ db ['default'] ['dbprefix']
解决了此问题.
但是,Doctrine不支持它,因为没有使用前缀创建实体类.因此找不到表格.
I am using Doctrine2 with codeigniter. my project has created but i have to add prefix in database table. In codeigniter I have solved this issue with dbprefix $db['default']['dbprefix']
.
But Doctrine not support it because Entity classes are not created with prefix. So it can't find Table.
我也想在原则中添加表前缀,而不更改原则的实体类名称.有没有可能添加一些前缀.
I want to add table prefix in doctrine also without change in Entity class name of doctrine. Is there any possibility to add some prefix.
我搜索了 TablePrefix 类,但是该类在我的Doctrine库中不起作用.
I have search TablePrefix Class but this class not working in my Doctrine library.
以前,创建的项目没有前缀表名(如"user")和实体注释也已使用"User"创建.但是现在我在所有表"my_user"中添加了前缀
Previously Project created without prefix table name like "user" and entity annotation has also created with "User". But now I added prefix in all table "my_user"
请帮助!!
推荐答案
您可以使用Doctrines事件管理器添加表前缀,如Doctrine文档中所述:
You can add a table prefix by using Doctrines event manager as described in the Doctrine documentation here:
在前面的问题中,simshaun给出了一个很好的示例,说明如何在交响乐中实现这一点:
In a previous question, simshaun has given a good example of how to implement this in symphony:
这篇关于在表名中添加前缀,而不会在Doctrine的注释中进行更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!