-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Conversation
if (isset($config['driver']) && $config['driver'] === 'odbc') { | ||
return $this->getOdbcDsn($config); | ||
} else { | ||
return $this->getSqlSrvDsn($config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this extra case?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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);
}
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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'
There was a problem hiding this comment.
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.
Not true. You can name the "connection" anything you want. The "driver" is what selects the correct driver. |
In the config/database.php file the 'default' is 'sqlsrv' 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 |
taylorotwell said that "What if odbc is an availble driver but they want to use the sqlsrv string? " 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? |
#13273