Skip to content

Loading…

DBAL-685: Add support for custom Oracle SID / Service name in PDO_Oracle driver #1907

Closed
doctrinebot opened this Issue · 2 comments

2 participants

@doctrinebot

Jira issue originally created by user michl:

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.

@doctrinebot

Comment created by @deeky666:

Patch supplied in PR: #471

@doctrinebot

Issue was closed with resolution "Fixed"

@deeky666 deeky666 was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.5 milestone
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.