在symfony2中设置Doctrine DBAL配置的driverOptions的正确方法 [英] Correct way to set the driverOptions for Doctrine DBAL configuration in symfony2
问题描述
我在配置文件中设置了 driverOptions ,如doctrine DBAL文档中所述。
I have set driverOptions in the config file as mentioned in the doctrine DBAL documentation.
但是这会给出错误
1/1 InvalidConfigurationException:doctrine.dbal.connections.pdoDevCon下的无法识别的选项driverOptions
1/1 InvalidConfigurationException: Unrecognized options "driverOptions" under "doctrine.dbal.connections.pdoDevCon"
我的配置文件是
dbal:
default_connection: pdoDevCon
connections:
pdoDevCon:
driver: %dev_database_driver% # <
host: %dev_database_host% # |
port: %dev_database_port% # | Defined in
user: %dev_database_user% # |
password: %dev_database_password% # <
charset: UTF8
driverOptions: {3: 2}
mapping_types:
enum: string
set: string
orm:
auto_generate_proxy_classes: %kernel.debug%
pdoDevCon:
connection: pdoDevCon
mappings:
AcmeDemoBundle: ~
AcmeHelloBundle: ~
我使用 PDO :: ATTR_ERRMODE作为3 PDO :: ERRMODE_EXCEPTION为2 ,即使我使用这些字符串。
I am using PDO::ATTR_ERRMODE as 3 PDO::ERRMODE_EXCEPTION as 2, it does not work even if i use the strings.
推荐答案
从 http://symfony.com/doc/master/reference/configuration/doctrine.html#doctrine-dbal-configuration
DoctrineBundle支持默认Doctrine驱动
接受的所有参数,转换为Symfony
强制执行的XML或YAML命名标准 。有关详细信息,请参阅Doctrine DBAL文档。
DoctrineBundle supports all parameters that default Doctrine drivers accept, converted to the XML or YAML naming standards that Symfony enforces. See the Doctrine DBAL documentation for more information.
没有 driverOptions
symfony yml配置文件,只需选项
There is no driverOptions
in symfony yml configuration file, just options
这篇关于在symfony2中设置Doctrine DBAL配置的driverOptions的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!