Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-685

Add support for custom Oracle SID / Service name in PDO_Oracle driver

    Details

    • Type: Task Task
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.5
    • Component/s: None
    • Security Level: All
    • Labels:

      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.

        Activity

          People

          • Assignee:
            Steve Müller
            Reporter:
            Michl Schmid
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: