Better connection management:
- No mandatory ODBC connection under Operating System admnistration - add all ODBC settings according official IBM documentation
This commit is contained in:
parent
b902a5e030
commit
85a8cacce5
@ -11,7 +11,55 @@ class IBMConnector extends Connector implements ConnectorInterface
|
||||
{
|
||||
$dsn = $this->getDsn($config);
|
||||
|
||||
$options = $this->getOptions($config);
|
||||
$options = [
|
||||
PDO::I5_ATTR_DBC_SYS_NAMING => false,
|
||||
PDO::I5_ATTR_COMMIT => PDO::I5_TXN_NO_COMMIT,
|
||||
PDO::I5_ATTR_JOB_SORT => false
|
||||
];
|
||||
|
||||
// Naming mode
|
||||
switch ($config['naming']) {
|
||||
case 1:
|
||||
$options[PDO::I5_ATTR_DBC_SYS_NAMING] = true;
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
$options[PDO::I5_ATTR_DBC_SYS_NAMING] = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// Isolation mode
|
||||
switch ($config['commitMode']) {
|
||||
case 1:
|
||||
$options[PDO::I5_ATTR_COMMIT] = PDO::I5_TXN_READ_COMMITTED;
|
||||
break;
|
||||
case 2:
|
||||
$options[PDO::I5_ATTR_COMMIT] = PDO::I5_TXN_READ_UNCOMMITTED;
|
||||
break;
|
||||
case 3:
|
||||
$options[PDO::I5_ATTR_COMMIT] = PDO::I5_TXN_REPEATABLE_READ;
|
||||
break;
|
||||
case 4:
|
||||
$options[PDO::I5_ATTR_COMMIT] = PDO::I5_TXN_SERIALIZABLE;
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
$options[PDO::I5_ATTR_COMMIT] = PDO::I5_TXN_NO_COMMIT;
|
||||
break;
|
||||
}
|
||||
|
||||
// Job sort mode
|
||||
switch ($config['jobSort']) {
|
||||
case 1:
|
||||
$options[PDO::I5_ATTR_DBC_SYS_NAMING] = true;
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
$options[PDO::I5_ATTR_DBC_SYS_NAMING] = false;
|
||||
break;
|
||||
}
|
||||
|
||||
$options = array_merge($this->getOptions($config), $options) ;
|
||||
|
||||
$connection = $this->createConnection($dsn, $config, $options);
|
||||
|
||||
|
@ -28,17 +28,70 @@ class ODBCConnector extends Connector implements ConnectorInterface
|
||||
protected function getDsn(array $config) {
|
||||
extract($config);
|
||||
|
||||
$dsn = "odbc:DRIVER={iSeries Access ODBC Driver};"
|
||||
. "SYSTEM=$database;"
|
||||
. "NAM=$i5_naming;"
|
||||
. "DATABASE=$i5_lib;"
|
||||
. "DBQ=$i5_libl;"
|
||||
. "DFT=$i5_date_fmt;"
|
||||
. "DSP=$i5_date_sep;"
|
||||
. "DEC=$i5_decimal_sep;"
|
||||
. "TFT=$i5_time_fmt;"
|
||||
. "TSP=$i5_time_sep;"
|
||||
. "CCSID=$ccsid";
|
||||
$dsn = "odbc:"
|
||||
// General settings
|
||||
. "DRIVER={iSeries Access ODBC Driver};"
|
||||
. "SYSTEM=$host;"
|
||||
. "UserID=$username;"
|
||||
. "Password=$password;"
|
||||
//Server settings
|
||||
. "DATABASE=$database;"
|
||||
. "SIGNON=$signon;"
|
||||
. "SSL=$ssl;"
|
||||
. "CommitMode=$commitMode;"
|
||||
. "ConnectionType=$connectionType;"
|
||||
. "DefaultLibraries=$defaultLibraries;"
|
||||
. "Naming=$naming;"
|
||||
. "UNICODESQL=$unicodeSql;"
|
||||
// Format settings
|
||||
. "DateFormat=$dateFormat;"
|
||||
. "DateSeperator=$dateSeperator;"
|
||||
. "Decimal=$decimal;"
|
||||
. "TimeFormat=$timeFormat;"
|
||||
. "TimeSeparator=$timeSeparator;"
|
||||
// Performances settings
|
||||
. "BLOCKFETCH=$blockFetch;"
|
||||
. "BlockSizeKB=$blockSizeKB;"
|
||||
. "AllowDataCompression=$allowDataCompression;"
|
||||
. "CONCURRENCY=$concurrency;"
|
||||
. "LAZYCLOSE=$lazyClose;"
|
||||
. "MaxFieldLength=$maxFieldLength;"
|
||||
. "PREFETCH=$prefetch;"
|
||||
. "QUERYTIMEOUT=$queryTimeout;"
|
||||
// Modules settings
|
||||
. "DefaultPkgLibrary=$defaultPkgLibrary;"
|
||||
. "DefaultPackage=$defaultPackage;"
|
||||
. "ExtendedDynamic=$extendedDynamic;"
|
||||
// Diagnostic settings
|
||||
. "QAQQINILibrary=$QAQQINILibrary;"
|
||||
. "SQDIAGCODE=$sqDiagCode;"
|
||||
// Sort settings
|
||||
. "LANGUAGEID=$languageId;"
|
||||
. "SORTTABLE=$sortTable;"
|
||||
. "SortSequence=$sortSequence;"
|
||||
. "SORTWEIGHT=$sortWeight;"
|
||||
// Conversion settings
|
||||
. "AllowUnsupportedChar=$allowUnsupportedChar;"
|
||||
. "CCSID=$ccsid;"
|
||||
. "GRAPHIC=$graphic;"
|
||||
. "ForceTranslation=$forceTranslation;"
|
||||
// Other settings
|
||||
. "ALLOWPROCCALLS=$allowProcCalls;"
|
||||
. "DB2SQLSTATES=$DB2SqlStates;"
|
||||
. "DEBUG=$debug;"
|
||||
. "TRUEAUTOCOMMIT=$trueAutoCommit;"
|
||||
. "CATALOGOPTIONS=$catalogOptions;"
|
||||
. "LibraryView=$libraryView;"
|
||||
. "ODBCRemarks=$ODBCRemarks;"
|
||||
. "SEARCHPATTERN=$searchPattern;"
|
||||
. "TranslationDLL=$translationDLL;"
|
||||
. "TranslationOption=$translationOption;"
|
||||
. "MAXTRACESIZE=$maxTraceSize;"
|
||||
. "MultipleTraceFiles=$multipleTraceFiles;"
|
||||
. "TRACE=$trace;"
|
||||
. "TRACEFILENAME=$traceFilename;"
|
||||
. "ExtendedColInfo=$extendedColInfo;"
|
||||
;
|
||||
|
||||
return $dsn;
|
||||
}
|
||||
|
@ -7,6 +7,29 @@ use Cooperl\Database\DB2\Query\Grammars\DB2Grammar;
|
||||
|
||||
class DB2Processor extends Processor {
|
||||
|
||||
/**
|
||||
* Process the results of a "select" query.
|
||||
*
|
||||
* @param \Illuminate\Database\Query\Builder $query
|
||||
* @param array $results
|
||||
* @return array
|
||||
*/
|
||||
/*public function processSelect(Builder $query, $results)
|
||||
{
|
||||
$results = array_map(function($result) {
|
||||
foreach (get_object_vars($result) as $field => $value) {
|
||||
if (is_string($value))
|
||||
{
|
||||
$result->$field = trim(preg_split('/[^\r\n\t\x20-\x7E\xA0-\xFF]/', $value)[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}, $results);
|
||||
|
||||
return $results;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Process an "insert get ID" query.
|
||||
*
|
||||
|
@ -11,11 +11,11 @@ Valeurs définies pour le niveau d'isolation, pour PDO (mot clé "CMT" ou "Commi
|
||||
3 = Repeatable read (*ALL)
|
||||
4 = Serializable (*RR)
|
||||
|
||||
* i5_naming:
|
||||
* naming:
|
||||
0 = "sql" (as in schema.table)
|
||||
1 = "system" (as in schema/table)
|
||||
|
||||
* i5_date_fmt:
|
||||
* dateFormat:
|
||||
0 = yy/dd (*JUL)
|
||||
1 = mm/dd/yy (*MDY)
|
||||
2 = dd/mm/yy (*DMY)
|
||||
@ -25,25 +25,25 @@ Valeurs définies pour le niveau d'isolation, pour PDO (mot clé "CMT" ou "Commi
|
||||
6 = dd.mm.yyyy (*EUR)
|
||||
7 = yyyy-mm-dd (*JIS)
|
||||
|
||||
* i5_date_sep:
|
||||
* dateSeperator:
|
||||
0 = "/" (forward slash)
|
||||
1 = "-" (dash)
|
||||
2 = "." (period)
|
||||
3 = "," (comma)
|
||||
4 = " " (blank)
|
||||
|
||||
* i5_decimal_sep:
|
||||
* decimal:
|
||||
0 = "." (period)
|
||||
1 = "," (comma)
|
||||
|
||||
* i5_time_fmt:
|
||||
* timeFormat:
|
||||
0 = hh:mm:ss (*HMS)
|
||||
1 = hh:mm AM/PM (*USA)
|
||||
2 = hh.mm.ss (*ISO)
|
||||
3 = hh.mm.ss (*EUR)
|
||||
4 = hh:mm:ss (*JIS)
|
||||
|
||||
* i5_time_sep:
|
||||
* timeSeparator:
|
||||
0 = ":" (colon)
|
||||
1 = "." (period)
|
||||
2 = "," (comma)
|
||||
@ -61,51 +61,72 @@ return [
|
||||
|
||||
'connections' => [
|
||||
|
||||
'odbc' => [
|
||||
'driver' => 'odbc',
|
||||
'host' => '',
|
||||
'database' => '',
|
||||
'ibmi' => [
|
||||
'driver' => 'odbc' / 'ibm',
|
||||
// General settings
|
||||
'host' => 'gigc',
|
||||
'username' => '',
|
||||
'password' => '',
|
||||
'charset' => 'utf8',
|
||||
'ccsid' => 1208,
|
||||
//Server settings
|
||||
'database' => 'WRKRDBDIRE entry',
|
||||
'prefix' => '',
|
||||
'schema' => '',
|
||||
'i5_libl' => '',
|
||||
'i5_lib' => '',
|
||||
'i5_commit' => 0,
|
||||
'i5_naming' => 0,
|
||||
'i5_date_fmt' => 5,
|
||||
'i5_date_sep' => 0,
|
||||
'i5_decimal_sep' => 0,
|
||||
'i5_time_fmt' => 0,
|
||||
'i5_time_sep' => 0,
|
||||
'options' => [
|
||||
PDO::ATTR_CASE => PDO::CASE_LOWER,
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
PDO::ATTR_PERSISTENT => false
|
||||
]
|
||||
],
|
||||
|
||||
'ibm' => [
|
||||
'driver' => 'ibm',
|
||||
'host' => '',
|
||||
'database' => '',
|
||||
'username' => '',
|
||||
'password' => '',
|
||||
'charset' => 'utf8',
|
||||
'schema' => 'default schema',
|
||||
'signon' => 3,
|
||||
'ssl' => 0,
|
||||
'commitMode' => 2,
|
||||
'connectionType' => 0,
|
||||
'defaultLibraries' => '',
|
||||
'naming' => 0,
|
||||
'unicodeSql' => 0,
|
||||
// Format settings
|
||||
'dateFormat' => 5,
|
||||
'dateSeperator' => 0,
|
||||
'decimal' => 0,
|
||||
'timeFormat' => 0,
|
||||
'timeSeparator' => 0,
|
||||
// Performances settings
|
||||
'blockFetch' => 1,
|
||||
'blockSizeKB' => 32,
|
||||
'allowDataCompression' => 1,
|
||||
'concurrency' => 0,
|
||||
'lazyClose' => 0,
|
||||
'maxFieldLength' => 15360,
|
||||
'prefetch' => 0,
|
||||
'queryTimeout' => 1,
|
||||
// Modules settings
|
||||
'defaultPkgLibrary' => 'QGPL',
|
||||
'defaultPackage' => 'A/DEFAULT(IBM),2,0,1,0',
|
||||
'extendedDynamic' => 1,
|
||||
// Diagnostic settings
|
||||
'QAQQINILibrary' => '',
|
||||
'sqDiagCode' => '',
|
||||
// Sort settings
|
||||
'languageId' => 'ENU',
|
||||
'sortTable' => '',
|
||||
'sortSequence' => 0,
|
||||
'sortWeight' => 0,
|
||||
'jobSort' => 0,
|
||||
// Conversion settings
|
||||
'allowUnsupportedChar' => 0,
|
||||
'ccsid' => 1208,
|
||||
'prefix' => '',
|
||||
'schema' => '',
|
||||
'i5_libl' => '',
|
||||
'i5_lib' => '',
|
||||
'i5_commit' => 0,
|
||||
'i5_naming' => 0,
|
||||
'i5_date_fmt' => 5,
|
||||
'i5_date_sep' => 0,
|
||||
'i5_decimal_sep' => 0,
|
||||
'i5_time_fmt' => 0,
|
||||
'i5_time_sep' => 0,
|
||||
'graphic' => 0,
|
||||
'forceTranslation' => 0,
|
||||
// Other settings
|
||||
'allowProcCalls' => 0,
|
||||
'DB2SqlStates' => 0,
|
||||
'debug' => 0,
|
||||
'trueAutoCommit' => 0,
|
||||
'catalogOptions' => 3,
|
||||
'libraryView' => 0,
|
||||
'ODBCRemarks' => 0,
|
||||
'searchPattern' => 1,
|
||||
'translationDLL' => '',
|
||||
'translationOption' => 0,
|
||||
'maxTraceSize' => 0,
|
||||
'multipleTraceFiles' => 1,
|
||||
'trace' => 0,
|
||||
'traceFilename' => '',
|
||||
'extendedColInfo' => 0,
|
||||
'options' => [
|
||||
PDO::ATTR_CASE => PDO::CASE_LOWER,
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
|
Loading…
Reference in New Issue
Block a user