Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODBC Configuration problem within a Symfony application #22

Open
pierre-bec opened this issue Jul 18, 2022 · 1 comment
Open

ODBC Configuration problem within a Symfony application #22

pierre-bec opened this issue Jul 18, 2022 · 1 comment

Comments

@pierre-bec
Copy link

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

@phansys
Copy link
Contributor

phansys commented Mar 8, 2023

@pierre-bec, could you please share the output of composer show --latest 'doctrine/*'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants