Introduce SQLite resource type

refs #3381

Signed-off-by: Eric Lippmann <eric.lippmann@icinga.com>
This commit is contained in:
Uwe Ebel 2018-05-23 19:50:31 +02:00 committed by Eric Lippmann
parent c633c86db7
commit 4b5cf47cce
3 changed files with 122 additions and 90 deletions

View File

@ -45,6 +45,9 @@ class DbResourceForm extends Form
if (Platform::hasOciSupport()) {
$dbChoices['oci'] = 'Oracle (OCI8)';
}
if (Platform::hasSqliteSupport()) {
$dbChoices['sqlite'] = 'SQLite';
}
$offerPostgres = false;
$offerIbm = false;
@ -89,6 +92,17 @@ class DbResourceForm extends Form
'multiOptions' => $dbChoices
)
);
if ($dbChoice === 'sqlite') {
$this->addElement(
'text',
'dbname',
array(
'required' => true,
'label' => $this->translate('Database Name'),
'description' => $this->translate('The name of the database to use')
)
);
} else {
$this->addElement(
'text',
'host',
@ -133,6 +147,7 @@ class DbResourceForm extends Form
'password',
'password',
array(
'required' => true,
'renderPassword' => true,
'label' => $this->translate('Password'),
'description' => $this->translate('The password to use for authentication')
@ -201,6 +216,7 @@ class DbResourceForm extends Form
)
);
}
}
return $this;
}

View File

@ -420,4 +420,16 @@ class Platform
{
return static::extensionLoaded('pdo_pgsql') && static::classExists('Zend_Db_Adapter_Pdo_Pgsql');
}
/**
* Return whether it's possible to connect to a SQLite database
*
* Checks whether the sqlite pdo extension has been loaded and the Zend framework adapter for SQLite is available
*
* @return bool
*/
public static function hasSqliteSupport()
{
return static::extensionLoaded('pdo_sqlite') && static::classExists('Zend_Db_Adapter_Pdo_Sqlite');
}
}

View File

@ -224,6 +224,10 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp
$adapter = 'Pdo_Ibm';
$defaultPort = 50000;
break;
case 'sqlite':
$adapter = 'Pdo_Sqlite';
$defaultPort = 0; // Dummy port because a value is required
break;
default:
throw new ConfigurationError(
'Backend "%s" is not supported',