Fix syntax

This commit is contained in:
Maxime Rault 2016-09-08 08:19:46 +02:00
parent 0f5cbff09d
commit e26b9b4bcb

View File

@ -40,47 +40,73 @@ class ODBCConnector extends Connector implements ConnectorInterface
*/ */
protected function getDsn(array $config) protected function getDsn(array $config)
{ {
$dsnParts = [ extract($config);
'odbc:DRIVER=%s', 'SYSTEM=%s', 'UserID=%s', 'Password=%s', 'DATABASE=%s', 'SIGNON=%s', 'SSL=%s',
'CommitMode=%s', 'ConnectionType=%s', 'DefaultLibraries=%s', 'Naming=%s', 'UNICODESQL=%s', 'DateFormat=%s',
'DateSeperator=%s', 'Decimal=%s', 'TimeFormat=%s', 'TimeSeparator=%s', 'BLOCKFETCH=%s', 'BlockSizeKB=%s',
'AllowDataCompression=%s', 'CONCURRENCY=%s', 'LAZYCLOSE=%s', 'MaxFieldLength=%s', 'PREFETCH=%s',
'QUERYTIMEOUT=%s', 'DefaultPkgLibrary=%s', 'DefaultPackage=%s', 'ExtendedDynamic=%s', 'QAQQINILibrary=%s',
'SQDIAGCODE=%s', 'LANGUAGEID=%s', 'SORTTABLE=%s', 'SortSequence=%s', 'SORTWEIGHT=%s',
'AllowUnsupportedChar=%s', 'CCSID=%s', 'GRAPHIC=%s', 'ForceTranslation=%s', 'ALLOWPROCCALLS=%s',
'DB2SQLSTATES=%s', 'DEBUG=%s', 'TRUEAUTOCOMMIT=%s', 'CATALOGOPTIONS=%s', 'LibraryView=%s', 'ODBCRemarks=%s',
'SEARCHPATTERN=%s', 'TranslationDLL=%s', 'TranslationOption=%s', 'MAXTRACESIZE=%s', 'MultipleTraceFiles=%s',
'TRACE=%s', 'TRACEFILENAME=%s', 'ExtendedColInfo=%s',
'', // Just to add a semicolon to the end of string
];
$dsnConfig = [ $dsn = "odbc:"
// General settings // General settings
$config['driverName'], $config['host'], $config['username'], $config['password'], . "DRIVER=$driverName;"
//Server settings . "SYSTEM=$host;"
$config['database'], $config['signon'], $config['ssl'], $config['commitMode'], $config['connectionType'], . "UserID=$username;"
$config['defaultLibraries'], $config['naming'], $config['unicodeSql'], . "Password=$password;"
// Format settings //Server settings
$config['dateFormat'], $config['dateSeperator'], $config['decimal'], $config['timeFormat'], . "DATABASE=$database;"
$config['timeSeparator'], . "SIGNON=$signon;"
// Performances settings . "SSL=$ssl;"
$config['blockFetch'], $config['blockSizeKB'], $config['allowDataCompression'], $config['concurrency'], . "CommitMode=$commitMode;"
$config['lazyClose'], $config['maxFieldLength'], $config['prefetch'], $config['queryTimeout'], . "ConnectionType=$connectionType;"
// Modules settings . "DefaultLibraries=$defaultLibraries;"
$config['defaultPkgLibrary'], $config['defaultPackage'], $config['extendedDynamic'], . "Naming=$naming;"
// Diagnostic settings . "UNICODESQL=$unicodeSql;"
$config['QAQQINILibrary'], $config['sqDiagCode'], // Format settings
// Sort settings . "DateFormat=$dateFormat;"
$config['languageId'], $config['sortTable'], $config['sortSequence'], $config['sortWeight'], . "DateSeperator=$dateSeperator;"
// Conversion settings . "Decimal=$decimal;"
$config['allowUnsupportedChar'], $config['ccsid'], $config['graphic'], $config['forceTranslation'], . "TimeFormat=$timeFormat;"
// Other settings . "TimeSeparator=$timeSeparator;"
$config['allowProcCalls'], $config['DB2SqlStates'], $config['debug'], $config['trueAutoCommit'], // Performances settings
$config['catalogOptions'], $config['libraryView'], $config['ODBCRemarks'], $config['searchPattern'], . "BLOCKFETCH=$blockFetch;"
$config['translationDLL'], $config['translationOption'], $config['maxTraceSize'], . "BlockSizeKB=$blockSizeKB;"
$config['multipleTraceFiles'], $config['trace'], $config['traceFilename'], $config['extendedColInfo'], . "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 sprintf(implode(';', $dsnParts), ...$dsnConfig); return $dsn;
} }
} }