Skip to content

ODBC Configuration problem within a Symfony application #22

@pierre-bec

Description

@pierre-bec

Hello,

We tested this driver in order to take advantage of the odbc connection it offers with DB2 and by integrating it into a Symfony application. We encountered a problem during the configuration via the doctrine.yaml file, a file integrated with Symfony, where when we indicate the DSN, the tag is not recognized and throws an exception.

Unrecognized option "dsn" under "doctrine.dbal.connections.default"
doctrine:
    dbal:
        default_connection: default

        connections:
            default:
                driver_class: 'DoctrineDbalIbmi\Driver\OdbcDriver'
                dsn: 'Driver={IBM i Access ODBC Driver};System=localhost;Database=db;AlwaysCalculateResultLength=1;DEBUG=524288;NAM=1;DBQ=lib'
                dbname: 'dbname'
                user: 'uid'
                password: 'pwd'
                options:
                    i5_lib: 'lib'

By replacing the recovery of "dsn" by "host" in the file DoctrineDbalIbmi\Driver\OdbcDriver and "dsn" by "host" in the configuration file everything works fine.

public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
    {
        $params['dsn'] = 'odbc:' . $params['host'];
        $username = (!is_null($username)) ? $username : $params['username'];
        $password = (!is_null($password)) ? $password : $params['password'];

        return new OdbcIBMiConnection($params, $username, $password, $driverOptions);
    }

Is this an error on our part or an interesting modification to make in order to be able to configure this driver in a standardized way within a Symfony application ?

Pierre

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions