I am currently in the process of migrating a legacy app over to symfony2, the problem is that I have a lot of mysql enum columns, I know that doctrine does not support enum data types and that one workaround is to store as a string but I would really lose the ability to properly sort the data because varchars are a lot slower, I do have a lot of tables with the enum data types and modifying the schema would be really hard, what are my options?? What can you suggest that will make a transition to symfony2 a lot smoother?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You have two solution
- Solution 1: Mapping to Varchars
- Solution 2: Defining a Type
for more information please consult this link: Mysql Enums doctrine
回答2:
Try this it worked for me
http://symfony.com/doc/current/reference/configuration/doctrine.html#reference-dbal-configuration
in the app/config/config.yml file add
mapping_types:
enum: string
e.g below
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
mapping_types:
enum: string
then you can use e.g.
@ORM\Column(type="string", columnDefinition="ENUM('A', 'B')")