Commit e0e5bf49 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge pull request #471 from deeky666/DBAL-685

[DBAL-685] Add servicename connection parameter to Oracle drivers
parents 9bc6cd02 45113e7d
...@@ -179,6 +179,14 @@ pdo\_oci / oci8 ...@@ -179,6 +179,14 @@ pdo\_oci / oci8
- ``host`` (string): Hostname of the database to connect to. - ``host`` (string): Hostname of the database to connect to.
- ``port`` (integer): Port of the database to connect to. - ``port`` (integer): Port of the database to connect to.
- ``dbname`` (string): Name of the database/schema to connect to. - ``dbname`` (string): Name of the database/schema to connect to.
- ``servicename`` (string): Optional name by which clients can
connect to the database instance. Will be used as Oracle's
``SID`` connection parameter if given and defaults to Doctrine's
``dbname`` connection parameter value.
- ``service`` (boolean): Whether to use Oracle's ``SERVICE_NAME``
connection parameter in favour of ``SID`` when connecting. The
value for this will be read from Doctrine's ``servicename`` if
given, ``dbname`` otherwise.
- ``pooled`` (boolean): Whether to enable database resident - ``pooled`` (boolean): Whether to enable database resident
connection pooling. connection pooling.
- ``charset`` (string): The charset used when connecting to the - ``charset`` (string): The charset used when connecting to the
......
...@@ -66,18 +66,24 @@ class Driver implements \Doctrine\DBAL\Driver ...@@ -66,18 +66,24 @@ class Driver implements \Doctrine\DBAL\Driver
$dsn .= '(PORT=1521)'; $dsn .= '(PORT=1521)';
} }
$database = 'SID=' . $params['dbname']; $serviceName = $params['dbname'];
if ( ! empty($params['servicename'])) {
$serviceName = $params['servicename'];
}
$service = 'SID=' . $serviceName;
$pooled = ''; $pooled = '';
if (isset($params['service']) && $params['service'] == true) { if (isset($params['service']) && $params['service'] == true) {
$database = 'SERVICE_NAME=' . $params['dbname']; $service = 'SERVICE_NAME=' . $serviceName;
} }
if (isset($params['pooled']) && $params['pooled'] == true) { if (isset($params['pooled']) && $params['pooled'] == true) {
$pooled = '(SERVER=POOLED)'; $pooled = '(SERVER=POOLED)';
} }
$dsn .= '))(CONNECT_DATA=(' . $database . ')' . $pooled . '))'; $dsn .= '))(CONNECT_DATA=(' . $service . ')' . $pooled . '))';
} else { } else {
$dsn .= $params['dbname']; $dsn .= $params['dbname'];
} }
......
...@@ -68,18 +68,24 @@ class Driver implements \Doctrine\DBAL\Driver ...@@ -68,18 +68,24 @@ class Driver implements \Doctrine\DBAL\Driver
$dsn .= '(PORT=1521)'; $dsn .= '(PORT=1521)';
} }
$database = 'SID=' . $params['dbname']; $serviceName = $params['dbname'];
$pooled = '';
if ( ! empty($params['servicename'])) {
$serviceName = $params['servicename'];
}
$service = 'SID=' . $serviceName;
$pooled = '';
if (isset($params['service']) && $params['service'] == true) { if (isset($params['service']) && $params['service'] == true) {
$database = 'SERVICE_NAME=' . $params['dbname']; $service = 'SERVICE_NAME=' . $serviceName;
} }
if (isset($params['pooled']) && $params['pooled'] == true) { if (isset($params['pooled']) && $params['pooled'] == true) {
$pooled = '(SERVER=POOLED)'; $pooled = '(SERVER=POOLED)';
} }
$dsn .= '))(CONNECT_DATA=(' . $database . ')' . $pooled . '))'; $dsn .= '))(CONNECT_DATA=(' . $service . ')' . $pooled . '))';
} else { } else {
$dsn .= $params['dbname']; $dsn .= $params['dbname'];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment