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

[5.2] Added sqlserver odbc connection support #13298

Merged
merged 7 commits into from
Apr 27, 2016
Merged

[5.2] Added sqlserver odbc connection support #13298

merged 7 commits into from
Apr 27, 2016

Conversation

eddy8
Copy link
Contributor

@eddy8 eddy8 commented Apr 25, 2016

if (isset($config['driver']) && $config['driver'] === 'odbc') {
return $this->getOdbcDsn($config);
} else {
return $this->getSqlSrvDsn($config);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this extra case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the isset check either. It's guaranteed to be there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just do:

        if (in_array('dblib', $this->getAvailableDrivers())) {
            return $this->getDblibDsn($config);
        } elseif (in_array('odbc', $this->getAvailableDrivers()) && $config['driver'] === 'odbc') {
            return $this->getOdbcDsn($config);
        } else {
            return $this->getSqlSrvDsn($config);
        }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is $config['driver'] === 'odbc' ever true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DB_CONNECTION is 'sqlsrv' and driver is 'odbc'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if odbc is an availble driver but they want to use the sqlsrv string? By taylorotwell.

@GrahamCampbell
Copy link
Member

DB_CONNECTION is 'sqlsrv' and driver is 'odbc'

Not true. You can name the "connection" anything you want. The "driver" is what selects the correct driver.

@eddy8
Copy link
Contributor Author

eddy8 commented Apr 27, 2016

In the config/database.php file the 'default' is 'sqlsrv' and the connections['sqlsrv']['driver'] is 'odbc'

@GrahamCampbell
Copy link
Member

and the connections['sqlsrv']['driver'] is 'odbc'

If you do that, we'll never resolve the sqlsvr driver in the first place though?

https://github.com/laravel/laravel/blob/5.1/config/database.php#L79

@eddy8
Copy link
Contributor Author

eddy8 commented Apr 27, 2016

taylorotwell said that "What if odbc is an availble driver but they want to use the sqlsrv string? "
you are right! if connections['sqlsrv']['driver'] is 'odbc', then "Unsupported driver [odbc]" error will be raised.

i think we can add a new config value connections['sqlsrv']['odbc'], if it's value is true, then use odbc driver, otherwise use sqlsrv driver. What do you think about?

@taylorotwell taylorotwell merged commit 3dcd37a into laravel:5.2 Apr 27, 2016
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

Successfully merging this pull request may close these issues.

3 participants