-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from llevering/master
Laravel 6+ support and auto discovery
- Loading branch information
Showing
2 changed files
with
82 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |