无法识别的选项" mapping_types"通过多个连接

时间:2015-05-05 08:59:48

标签: php symfony doctrine-orm dbal

我试图添加" enum"键入我的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

这是我的配置,我收到了错误:

  [Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]  
  Unrecognized option "mapping_types" under "doctrine.dbal"    

我还尝试将它放在connection2下面并删除了default_connection,因为我找到了解决这个问题的答案。但这些问题并没有多重关系。

1 个答案:

答案 0 :(得分:9)

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