DbConnection: Make host optional for Oracle connections

This commit is contained in:
Markus Frosch 2018-12-04 15:50:53 +01:00
parent 63cb9d7283
commit 2df8132c46
2 changed files with 13 additions and 2 deletions

View File

@ -58,6 +58,12 @@ class DbResourceForm extends Form
$offerMysql = true; $offerMysql = true;
} }
if ($dbChoice === 'oracle') {
$hostIsRequired = false;
} else {
$hostIsRequired = true;
}
$socketInfo = ''; $socketInfo = '';
if ($offerPostgres) { if ($offerPostgres) {
$socketInfo = $this->translate( $socketInfo = $this->translate(
@ -104,7 +110,7 @@ class DbResourceForm extends Form
'text', 'text',
'host', 'host',
array ( array (
'required' => true, 'required' => $hostIsRequired,
'label' => $this->translate('Host'), 'label' => $this->translate('Host'),
'description' => $this->translate('The hostname of the database') 'description' => $this->translate('The hostname of the database')
. ($socketInfo ? '. ' . $socketInfo : ''), . ($socketInfo ? '. ' . $socketInfo : ''),

View File

@ -215,6 +215,11 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp
case 'oracle': case 'oracle':
$adapter = 'Pdo_Oci'; $adapter = 'Pdo_Oci';
$defaultPort = 1521; $defaultPort = 1521;
// remove host parameter when not configured
if (empty($this->config->host)) {
unset($adapterParamaters['host']);
}
break; break;
case 'pgsql': case 'pgsql':
$adapter = 'Pdo_Pgsql'; $adapter = 'Pdo_Pgsql';
@ -555,7 +560,7 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp
'Connection to %s as %s on %s:%s successful', 'Connection to %s as %s on %s:%s successful',
$config['dbname'], $config['dbname'],
$config['username'], $config['username'],
$config['host'], array_key_exists('host', $config) ? $config['host'] : '(none)',
$config['port'] $config['port']
)); ));
switch ($this->dbType) { switch ($this->dbType) {