[DBAL-685] Add support for custom Oracle SID / Service name in PDO_Oracle driver Created: 29/Jan/13  Updated: 29/Dec/13  Resolved: 29/Dec/13

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: 2.0
Fix Version/s: 2.5
Security Level: All

Type: Task Priority: Major
Reporter: Michl Schmid Assignee: Steve Müller
Resolution: Fixed Votes: 0
Labels: oracle


 Description   

Some Oracle customer databases are set up having different settings for their "DBNAME" and "SID" / "SERVICE" property. (DBNAME != SID)

So, hereing it's currently not possible to connect via the PDO_Oracle driver (Class: Doctrine\DBAL\Driver\PDOOracle\Driver) as it uses the DBNAME value by default as value for SID / SERVICE in the _constructPdoDsn() method. (DBNAME = SID)

A solution would be to add an additional config param like "servicename" and pass it's value into _constructPdoDsn().

An updated version of the method could look like:


private function _constructPdoDsn(array $params)
{
$dsn = 'oci:';
if (isset($params['host']) && $params['host'] != '') {
$dsn .= 'dbname=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)' .
'(HOST=' . $params['host'] . ')';

if (isset($params['port']))

{ $dsn .= '(PORT=' . $params['port'] . ')'; }

else

{ $dsn .= '(PORT=1521)'; }

if (isset($params['servicename']) && $params['servicename'] != '')

{ $servicename = $params['servicename']; }

else

{ $servicename = $params['dbname']; }

if (isset($params['service']) && $params['service'] == true)

{ $dsn .= '))(CONNECT_DATA=(SERVICE_NAME=' . $servicename . ')))'; }

else

{ $dsn .= '))(CONNECT_DATA=(SID=' . $servicename . ')))'; }

} else

{ $dsn .= 'dbname=' . $params['dbname']; }

if (isset($params['charset']))

{ $dsn .= ';charset=' . $params['charset']; }

return $dsn;
}


The only workaround for me is right now to use the "standard" PHP OCI / OCI8 functions with the correct SID / Service in it's DSN.



 Comments   
Comment by Steve Müller [ 27/Dec/13 ]

Patch supplied in PR: https://github.com/doctrine/dbal/pull/471

Generated at Sat Nov 29 02:43:34 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.