Add z/OS compatibility to DB2 Service Provider

This commit is contained in:
Lucas Mezêncio 2016-08-19 14:09:39 -03:00
parent 92f6800a01
commit 81cb89a639
3 changed files with 15 additions and 4 deletions

View File

@ -2,6 +2,7 @@
namespace Cooperl\Database\DB2;
use Cooperl\Database\DB2\Query\Processors\DB2ZOSProcessor;
use PDO;
use Illuminate\Database\Connection;
@ -110,6 +111,10 @@ class DB2Connection extends Connection
*/
protected function getDefaultPostProcessor()
{
if ($this->config['driver'] == 'odbczos') {
return new DB2ZOSProcessor();
}
return new DB2Processor();
}
}

View File

@ -4,6 +4,7 @@ namespace Cooperl\Database\DB2;
use Cooperl\Database\DB2\Connectors\ODBCConnector;
use Cooperl\Database\DB2\Connectors\IBMConnector;
use Cooperl\Database\DB2\Connectors\ODBCZOSConnector;
use Illuminate\Support\ServiceProvider;
use Config;
@ -50,8 +51,8 @@ class DB2ServiceProvider extends ServiceProvider
// Extend the connections with pdo_odbc and pdo_ibm drivers
foreach (Config::get('database.connections') as $conn => $config) {
// Only use configurations that feature a "odbc" or "ibm" driver
if (!isset($config['driver']) || !in_array($config['driver'], ['odbc', 'ibm'])) {
// Only use configurations that feature a "odbc", "ibm" or "odbczos" driver
if (!isset($config['driver']) || !in_array($config['driver'], ['odbc', 'ibm', 'odbczos'])) {
continue;
}
@ -61,6 +62,10 @@ class DB2ServiceProvider extends ServiceProvider
case 'odbc':
$connector = new ODBCConnector();
break;
case 'odbczos':
$connector = new ODBCZOSConnector();
break;
case 'ibm':
default:

View File

@ -57,11 +57,11 @@ PDO::CASE_NATURAL
*/
return [
'connections' => [
'ibmi' => [
'driver' => 'odbc' / 'ibm',
'driver' => 'odbc' / 'ibm' / 'odbczos',
'driverName' => '{IBM i Access ODBC Driver}' / '{iSeries Access ODBC Driver}',
// General settings
'host' => 'server',
@ -71,6 +71,7 @@ return [
'database' => 'WRKRDBDIRE entry',
'prefix' => '',
'schema' => 'default schema',
'port' => 50000,
'signon' => 3,
'ssl' => 0,
'commitMode' => 2,