Skip to content

Commit e26b9b4

Browse files
author
Maxime Rault
committed
Fix syntax
1 parent 0f5cbff commit e26b9b4

File tree

1 file changed

+66
-40
lines changed

1 file changed

+66
-40
lines changed

src/Connectors/ODBCConnector.php

Lines changed: 66 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -40,47 +40,73 @@ public function connect(array $config)
4040
*/
4141
protected function getDsn(array $config)
4242
{
43-
$dsnParts = [
44-
'odbc:DRIVER=%s', 'SYSTEM=%s', 'UserID=%s', 'Password=%s', 'DATABASE=%s', 'SIGNON=%s', 'SSL=%s',
45-
'CommitMode=%s', 'ConnectionType=%s', 'DefaultLibraries=%s', 'Naming=%s', 'UNICODESQL=%s', 'DateFormat=%s',
46-
'DateSeperator=%s', 'Decimal=%s', 'TimeFormat=%s', 'TimeSeparator=%s', 'BLOCKFETCH=%s', 'BlockSizeKB=%s',
47-
'AllowDataCompression=%s', 'CONCURRENCY=%s', 'LAZYCLOSE=%s', 'MaxFieldLength=%s', 'PREFETCH=%s',
48-
'QUERYTIMEOUT=%s', 'DefaultPkgLibrary=%s', 'DefaultPackage=%s', 'ExtendedDynamic=%s', 'QAQQINILibrary=%s',
49-
'SQDIAGCODE=%s', 'LANGUAGEID=%s', 'SORTTABLE=%s', 'SortSequence=%s', 'SORTWEIGHT=%s',
50-
'AllowUnsupportedChar=%s', 'CCSID=%s', 'GRAPHIC=%s', 'ForceTranslation=%s', 'ALLOWPROCCALLS=%s',
51-
'DB2SQLSTATES=%s', 'DEBUG=%s', 'TRUEAUTOCOMMIT=%s', 'CATALOGOPTIONS=%s', 'LibraryView=%s', 'ODBCRemarks=%s',
52-
'SEARCHPATTERN=%s', 'TranslationDLL=%s', 'TranslationOption=%s', 'MAXTRACESIZE=%s', 'MultipleTraceFiles=%s',
53-
'TRACE=%s', 'TRACEFILENAME=%s', 'ExtendedColInfo=%s',
54-
'', // Just to add a semicolon to the end of string
55-
];
43+
extract($config);
5644

57-
$dsnConfig = [
58-
// General settings
59-
$config['driverName'], $config['host'], $config['username'], $config['password'],
60-
//Server settings
61-
$config['database'], $config['signon'], $config['ssl'], $config['commitMode'], $config['connectionType'],
62-
$config['defaultLibraries'], $config['naming'], $config['unicodeSql'],
63-
// Format settings
64-
$config['dateFormat'], $config['dateSeperator'], $config['decimal'], $config['timeFormat'],
65-
$config['timeSeparator'],
66-
// Performances settings
67-
$config['blockFetch'], $config['blockSizeKB'], $config['allowDataCompression'], $config['concurrency'],
68-
$config['lazyClose'], $config['maxFieldLength'], $config['prefetch'], $config['queryTimeout'],
69-
// Modules settings
70-
$config['defaultPkgLibrary'], $config['defaultPackage'], $config['extendedDynamic'],
71-
// Diagnostic settings
72-
$config['QAQQINILibrary'], $config['sqDiagCode'],
73-
// Sort settings
74-
$config['languageId'], $config['sortTable'], $config['sortSequence'], $config['sortWeight'],
75-
// Conversion settings
76-
$config['allowUnsupportedChar'], $config['ccsid'], $config['graphic'], $config['forceTranslation'],
77-
// Other settings
78-
$config['allowProcCalls'], $config['DB2SqlStates'], $config['debug'], $config['trueAutoCommit'],
79-
$config['catalogOptions'], $config['libraryView'], $config['ODBCRemarks'], $config['searchPattern'],
80-
$config['translationDLL'], $config['translationOption'], $config['maxTraceSize'],
81-
$config['multipleTraceFiles'], $config['trace'], $config['traceFilename'], $config['extendedColInfo'],
82-
];
45+
$dsn = "odbc:"
46+
// General settings
47+
. "DRIVER=$driverName;"
48+
. "SYSTEM=$host;"
49+
. "UserID=$username;"
50+
. "Password=$password;"
51+
//Server settings
52+
. "DATABASE=$database;"
53+
. "SIGNON=$signon;"
54+
. "SSL=$ssl;"
55+
. "CommitMode=$commitMode;"
56+
. "ConnectionType=$connectionType;"
57+
. "DefaultLibraries=$defaultLibraries;"
58+
. "Naming=$naming;"
59+
. "UNICODESQL=$unicodeSql;"
60+
// Format settings
61+
. "DateFormat=$dateFormat;"
62+
. "DateSeperator=$dateSeperator;"
63+
. "Decimal=$decimal;"
64+
. "TimeFormat=$timeFormat;"
65+
. "TimeSeparator=$timeSeparator;"
66+
// Performances settings
67+
. "BLOCKFETCH=$blockFetch;"
68+
. "BlockSizeKB=$blockSizeKB;"
69+
. "AllowDataCompression=$allowDataCompression;"
70+
. "CONCURRENCY=$concurrency;"
71+
. "LAZYCLOSE=$lazyClose;"
72+
. "MaxFieldLength=$maxFieldLength;"
73+
. "PREFETCH=$prefetch;"
74+
. "QUERYTIMEOUT=$queryTimeout;"
75+
// Modules settings
76+
. "DefaultPkgLibrary=$defaultPkgLibrary;"
77+
. "DefaultPackage=$defaultPackage;"
78+
. "ExtendedDynamic=$extendedDynamic;"
79+
// Diagnostic settings
80+
. "QAQQINILibrary=$QAQQINILibrary;"
81+
. "SQDIAGCODE=$sqDiagCode;"
82+
// Sort settings
83+
. "LANGUAGEID=$languageId;"
84+
. "SORTTABLE=$sortTable;"
85+
. "SortSequence=$sortSequence;"
86+
. "SORTWEIGHT=$sortWeight;"
87+
// Conversion settings
88+
. "AllowUnsupportedChar=$allowUnsupportedChar;"
89+
. "CCSID=$ccsid;"
90+
. "GRAPHIC=$graphic;"
91+
. "ForceTranslation=$forceTranslation;"
92+
// Other settings
93+
. "ALLOWPROCCALLS=$allowProcCalls;"
94+
. "DB2SQLSTATES=$DB2SqlStates;"
95+
. "DEBUG=$debug;"
96+
. "TRUEAUTOCOMMIT=$trueAutoCommit;"
97+
. "CATALOGOPTIONS=$catalogOptions;"
98+
. "LibraryView=$libraryView;"
99+
. "ODBCRemarks=$ODBCRemarks;"
100+
. "SEARCHPATTERN=$searchPattern;"
101+
. "TranslationDLL=$translationDLL;"
102+
. "TranslationOption=$translationOption;"
103+
. "MAXTRACESIZE=$maxTraceSize;"
104+
. "MultipleTraceFiles=$multipleTraceFiles;"
105+
. "TRACE=$trace;"
106+
. "TRACEFILENAME=$traceFilename;"
107+
. "ExtendedColInfo=$extendedColInfo;"
108+
;
83109

84-
return sprintf(implode(';', $dsnParts), ...$dsnConfig);
110+
return $dsn;
85111
}
86112
}

0 commit comments

Comments
 (0)