我正在尝试将"枚举"类型添加到我的symfony2 dbal连接中,但是我找不到方法。
doctrine:
dbal:
mapping_types:
enum: string
default_connection: default
connections:
default:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
connection2:
driver: "%database2_driver%"
host: "%database2_host%"
port: "%database2_port%"
dbname: "%database2_name%"
user: "%database2_user%"
password: "%database2_password%"
charset: LATIN1
这是我现在的配置,我会收到错误:
[SymfonyComponentConfigDefinitionExceptionInvalidConfigurationException]
Unrecognized option "mapping_types" under "doctrine.dbal"
我还试图将其放在连接下面2并删除Default_connection,因为我找到了解决此类问题的答案。但是这些问题没有多个连接。
mapping_types
必须位于具体连接下。因此,您需要下一个配置:
doctrine:
dbal:
default_connection: default
connections:
default:
mapping_types:
enum: string
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
connection2:
mapping_types:
enum: string
driver: "%database2_driver%"
host: "%database2_host%"
port: "%database2_port%"
dbname: "%database2_name%"
user: "%database2_user%"
password: "%database2_password%"
charset: LATIN1
在完整参考中,您必须在指定的连接元素下设置mapping_types
。
在此处查看更多详细信息
希望此帮助