Skip to content

Commit

Permalink
Merge pull request #11 from llevering/master
Browse files Browse the repository at this point in the history
Laravel 6+ support and auto discovery
  • Loading branch information
andreossido authored Aug 25, 2020
2 parents bbaa2be + e396b77 commit a6be5f5
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 74 deletions.
55 changes: 31 additions & 24 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
{
"name": "abram/laravel-odbc",
"description": "ODBC integration for Laravel framework ",
"type": "library",
"homepage": "https://github.com/andreossido/laravel-odbc",
"authors": [
{
"name": "Andrea Abram",
"email": "[email protected]",
"homepage": "https://github.com/andreossido",
"role": "Developer"
}
],
"require": {
"php": "^5.3.3 || >=7.0",
"illuminate/database": "~5.1",
"illuminate/support": "~5.1"
},
"autoload": {
"classmap": [
"src"
]
}
}
{
"name": "abram/laravel-odbc",
"description": "ODBC integration for Laravel framework ",
"type": "library",
"homepage": "https://github.com/andreossido/laravel-odbc",
"authors": [
{
"name": "Andrea Abram",
"email": "[email protected]",
"homepage": "https://github.com/andreossido",
"role": "Developer"
}
],
"require": {
"php": "^5.3.3 || >=7.0",
"illuminate/database": "~5.1 || >= 6.0",
"illuminate/support": "~5.1 || >= 6.0"
},
"autoload": {
"classmap": [
"src"
]
},
"extra": {
"laravel": {
"providers": [
"Abram\\Odbc\\ODBCServiceProvider"
]
}
}
}
101 changes: 51 additions & 50 deletions src/ODBCConnector.php
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
<?php
/**
* Created by PhpStorm.
* User: Andrea
* Date: 20/02/2018
* Time: 15:50
*/

namespace Abram\Odbc;

use Illuminate\Database\Connectors\Connector;
use Illuminate\Database\Connectors\ConnectorInterface;

class ODBCConnector extends Connector implements ConnectorInterface
{

/**
* Establish a database connection.
*
* @param array $config
*
* @return \PDO
* @internal param array $options
*
*/
public function connect(array $config)
{
$options = $this->getOptions($config);

$dsn = array_get($config, 'dsn');

$connection = $this->createConnection($dsn, $config, $options);

return $connection;
}

/**
* Create a new PDO connection instance.
*
* @param string $dsn
* @param string $username
* @param string $password
* @param array $options
* @return ODBCPdo
*/
protected function createPdoConnection($dsn, $username, $password, $options)
{
return new ODBCPdo($dsn, $username, $password);
}
}
<?php
/**
* Created by PhpStorm.
* User: Andrea
* Date: 20/02/2018
* Time: 15:50
*/

namespace Abram\Odbc;

use Illuminate\Database\Connectors\Connector;
use Illuminate\Database\Connectors\ConnectorInterface;
use Illuminate\Support\Arr;

class ODBCConnector extends Connector implements ConnectorInterface
{

/**
* Establish a database connection.
*
* @param array $config
*
* @return \PDO
* @internal param array $options
*
*/
public function connect(array $config)
{
$options = $this->getOptions($config);

$dsn = Arr::get($config, 'dsn');

$connection = $this->createConnection($dsn, $config, $options);

return $connection;
}

/**
* Create a new PDO connection instance.
*
* @param string $dsn
* @param string $username
* @param string $password
* @param array $options
* @return ODBCPdo
*/
protected function createPdoConnection($dsn, $username, $password, $options)
{
return new ODBCPdo($dsn, $username, $password);
}
}

0 comments on commit a6be5f5

Please sign in to comment.