Doctrine 2 - How to add custom DBAL driver? Doctrine 2 - How to add custom DBAL driver? symfony symfony

Doctrine 2 - How to add custom DBAL driver?


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 Configurationdoctrine:    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


You can use the option driverClass:

$connectionParams = array(    'driverClass' => 'YOUR_CUSTOM_CLASS_DB',   );$entityManager = \Doctrine\ORM\EntityManager::create($connectionParams, $config);