Doctrine 2 - How to add custom DBAL driver?

前端 未结 2 1080
面向向阳花
面向向阳花 2020-12-14 18:19

How can I add my custom driver without modifying DriverManager.php in the Doctrine2 core?

I have created a DBAL Driver for pdo_dblib and placed it insid

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-14 18:43

    You actually can, just leave the driver configuration option completlely out.

    All you need to define is the driver_class option. The driver is only used to do an internal lookup for the default driver classes, as long as you provide the class only, it will not fail doing the lookup.

    Btw: There is no way (in a complete default setup) to define this in the parameters.ini, you have to change it directly inside the config.yml

    Btw: due to another defect (driver falling back to mysql in on specific area), you may not set the charset in the configuration, as it will register an MySql event handler for setting the charset than.

    So my final doctrine config based on my mssql_* based implementation looks like the following and works without problems:

    # Doctrine Configuration
    doctrine:
        dbal:
            #driver:   %database_driver%
            driver_class: Doctrine\DBAL\Driver\MsSql\Driver
            host:     %database_host%
            port:     %database_port%
            dbname:   %database_name%
            user:     %database_user%
            password: %database_password%
            #charset:  UTF8
    
        orm:
            auto_generate_proxy_classes: %kernel.debug%
            auto_mapping: true
    

提交回复
热议问题