Commit a500e1ab authored by Steve Müller's avatar Steve Müller

Merge pull request #2307 from bobvandevijver/master

[Oracle] Add support for Easy Connect string as connection parameter
parents eb487974 1592855c
...@@ -295,7 +295,11 @@ pdo\_oci / oci8 ...@@ -295,7 +295,11 @@ pdo\_oci / oci8
- ``instancename`` (string): Optional parameter, complete whether to - ``instancename`` (string): Optional parameter, complete whether to
add the INSTANCE_NAME parameter in the connection. It is generally used add the INSTANCE_NAME parameter in the connection. It is generally used
to connect to an Oracle RAC server to select the name of a particular instance. to connect to an Oracle RAC server to select the name of a particular instance.
- ``connectstring`` (string): Complete Easy Connect connection descriptor,
see https://docs.oracle.com/database/121/NETAG/naming.htm. When using this option,
you will still need to provide the ``user`` and ``password`` parameters, but the other
parameters will no longer be used. Note that when using this parameter, the ``getHost``
and ``getPort`` methods from ``Doctrine\DBAL\Connection`` will no longer function as expected.
pdo\_sqlsrv / sqlsrv pdo\_sqlsrv / sqlsrv
^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^
......
...@@ -109,10 +109,14 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver ...@@ -109,10 +109,14 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
* *
* @return string * @return string
* *
* @link http://download.oracle.com/docs/cd/E11882_01/network.112/e10836/naming.htm * @link https://docs.oracle.com/database/121/NETAG/naming.htm
*/ */
protected function getEasyConnectString(array $params) protected function getEasyConnectString(array $params)
{ {
if ( ! empty($params['connectstring'])) {
return $params['connectstring'];
}
if ( ! empty($params['host'])) { if ( ! empty($params['host'])) {
if ( ! isset($params['port'])) { if ( ! isset($params['port'])) {
$params['port'] = 1521; $params['port'] = 1521;
......
...@@ -25,6 +25,25 @@ class AbstractOracleDriverTest extends AbstractDriverTest ...@@ -25,6 +25,25 @@ class AbstractOracleDriverTest extends AbstractDriverTest
$this->assertSame($params['user'], $this->driver->getDatabase($connection)); $this->assertSame($params['user'], $this->driver->getDatabase($connection));
} }
public function testReturnsDatabaseNameWithConnectDescriptor()
{
$params = array(
'user' => 'foo',
'password' => 'bar',
'connectionstring' => '(DESCRIPTION=' .
'(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))' .
'(CONNECT_DATA=(SERVICE_NAME=baz)))'
);
$connection = $this->getConnectionMock();
$connection->expects($this->once())
->method('getParams')
->will($this->returnValue($params));
$this->assertSame($params['user'], $this->driver->getDatabase($connection));
}
protected function createDriver() protected function createDriver()
{ {
return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractOracleDriver'); return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractOracleDriver');
......
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