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 #32

Open
cfreear opened this issue Mar 15, 2017 · 2 comments
Open

ODBC #32

cfreear opened this issue Mar 15, 2017 · 2 comments

Comments

@cfreear
Copy link

cfreear commented Mar 15, 2017

Hi, do you have an example of using odbc with this package? I'm not sure how I would put my connection details in the database config file for it.

@nunomazer
Copy link
Contributor

Sorry, we use it only as it' s described on README file. Never tried to connect it using ODBC.

@mainginski
Copy link
Collaborator

mainginski commented Mar 22, 2017

My mistake. The package in its pre-alpha versions was intended for Windows, so the connection was made from ODBC, where it replicated the entire structure of the Laravel Database. If you go to: vendor/laravel/framework/src/Illuminate/Database/Connectors/SqlServerConnector.php and change the getDsn function to:

    protected function getDsn(array $config)
    {	
        $arguments = [
            'Driver' => '{Adaptive Server Enterprise}',
            'server' => $config['host'],
        ];
        if (isset($config['database'])) {
            $arguments['db'] = $config['database'];
        }
	if (isset($config['port'])) {
            $arguments['port'] = $config['port'];
        }	
        if (isset($config['appname'])) {
            $arguments['APP'] = $config['appname'];
        }
        return $this->buildConnectString($arguments);
    }

and buildConnectString to:

protected function buildConnectString(array $arguments)
    {
        $options = array_map(function ($key) use ($arguments) {
            return sprintf('%s=%s', $key, $arguments[$key]);
        }, array_keys($arguments));

        return 'odbc:'.implode(';', $options);
    }

It will probably work with ODBC. But note that it's a very very old code and certainly not the best solution. But it is implementable.

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

No branches or pull requests

3 participants