mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 06:08:46 -04:00
Allow specify a config prefix for another database connection
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
2544ab48d4
commit
76541170bb
1 changed files with 7 additions and 6 deletions
|
|
@ -189,22 +189,23 @@ class ConnectionFactory {
|
|||
/**
|
||||
* Create the connection parameters for the config
|
||||
*
|
||||
* @param string $configPrefix
|
||||
* @return array
|
||||
*/
|
||||
public function createConnectionParams() {
|
||||
public function createConnectionParams(string $configPrefix = '') {
|
||||
$type = $this->config->getValue('dbtype', 'sqlite');
|
||||
|
||||
$connectionParams = [
|
||||
'user' => $this->config->getValue('dbuser', ''),
|
||||
'password' => $this->config->getValue('dbpassword', ''),
|
||||
'user' => $this->config->getValue($configPrefix . 'dbuser', $this->config->getValue('dbuser', '')),
|
||||
'password' => $this->config->getValue($configPrefix . 'dbpassword', $this->config->getValue('dbpassword', '')),
|
||||
];
|
||||
$name = $this->config->getValue('dbname', self::DEFAULT_DBNAME);
|
||||
$name = $this->config->getValue($configPrefix . 'dbname', $this->config->getValue('dbname', self::DEFAULT_DBNAME));
|
||||
|
||||
if ($this->normalizeType($type) === 'sqlite3') {
|
||||
$dataDir = $this->config->getValue("datadirectory", \OC::$SERVERROOT . '/data');
|
||||
$connectionParams['path'] = $dataDir . '/' . $name . '.db';
|
||||
} else {
|
||||
$host = $this->config->getValue('dbhost', '');
|
||||
$host = $this->config->getValue($configPrefix . 'dbhost', $this->config->getValue('dbhost', ''));
|
||||
$connectionParams = array_merge($connectionParams, $this->splitHostFromPortAndSocket($host));
|
||||
$connectionParams['dbname'] = $name;
|
||||
}
|
||||
|
|
@ -213,7 +214,7 @@ class ConnectionFactory {
|
|||
$connectionParams['sqlite.journal_mode'] = $this->config->getValue('sqlite.journal_mode', 'WAL');
|
||||
|
||||
//additional driver options, eg. for mysql ssl
|
||||
$driverOptions = $this->config->getValue('dbdriveroptions', null);
|
||||
$driverOptions = $this->config->getValue($configPrefix . 'dbdriveroptions', $this->config->getValue('dbdriveroptions', null));
|
||||
if ($driverOptions) {
|
||||
$connectionParams['driverOptions'] = $driverOptions;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue