Commit 45113e7d authored by Steve Müller's avatar Steve Müller

add servicename connection parameter to Oracle drivers

parent 2196da9c
...@@ -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'];
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'];
} }
......
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