mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-26 15:24:05 +02:00
Merge pull request #3463 from kobmaki/feature/Allow-to-interface-with-sqlite-databases-3381
Support SQLite resources
This commit is contained in:
commit
966148e8f0
@ -45,17 +45,17 @@ class DbResourceForm extends Form
|
||||
if (Platform::hasOciSupport()) {
|
||||
$dbChoices['oci'] = 'Oracle (OCI8)';
|
||||
}
|
||||
if (Platform::hasSqliteSupport()) {
|
||||
$dbChoices['sqlite'] = 'SQLite';
|
||||
}
|
||||
|
||||
$offerPostgres = false;
|
||||
$offerIbm = false;
|
||||
$offerMysql = false;
|
||||
$dbChoice = isset($formData['db']) ? $formData['db'] : key($dbChoices);
|
||||
if ($dbChoice === 'pgsql') {
|
||||
$offerPostgres = true;
|
||||
} elseif ($dbChoice === 'mysql') {
|
||||
$offerMysql = true;
|
||||
} elseif ($dbChoice === 'ibm') {
|
||||
$offerIbm = true;
|
||||
}
|
||||
|
||||
$socketInfo = '';
|
||||
@ -89,6 +89,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 +144,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 +213,7 @@ class DbResourceForm extends Form
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
@ -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',
|
||||
|
Loading…
x
Reference in New Issue
Block a user