From 57f882b0a875591bb58816da33291bdef181c3fd Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Fri, 15 Jul 2011 15:29:53 +0200 Subject: [PATCH] bacula-web: Fixed bug in DSN construction for SQLite database support --- gui/bacula-web/config/config.php.sample | 2 +- gui/bacula-web/includes/cfg/config.class.php | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/gui/bacula-web/config/config.php.sample b/gui/bacula-web/config/config.php.sample index ddddd521b3..8c0d7754bc 100644 --- a/gui/bacula-web/config/config.php.sample +++ b/gui/bacula-web/config/config.php.sample @@ -35,7 +35,7 @@ // SQLite bacula catalog $config[0]['label'] = 'Dev backup server'; - $config[0]['db_path'] = '/path/to/database/db.sdb'; + $config[0]['db_name'] = '/path/to/database/db.sdb'; If you want to configure more than one catalog in Bacula-Web, just copy the first parameters and increment by one the index diff --git a/gui/bacula-web/includes/cfg/config.class.php b/gui/bacula-web/includes/cfg/config.class.php index 070fd2cdb9..76f3e976c4 100644 --- a/gui/bacula-web/includes/cfg/config.class.php +++ b/gui/bacula-web/includes/cfg/config.class.php @@ -85,6 +85,26 @@ $dsn['phptype'] = $this->catalogs[$catalog_id]["db_type"]; return $dsn; } + + public function getDSN( $catalog_id ) + { + $dsn = ''; + + switch( $this->catalogs[$catalog_id]['db_type'] ) + { + case 'mysql': + case 'pgsql': + $dsn = $this->catalogs[$catalog_id]['db_type'] . ':'; + $dsn .= 'dbname=' . $this->catalogs[$catalog_id]['db_name'] . ';'; + $dsn .= 'host=' . $this->catalogs[$catalog_id]['host']; + break; + case 'sqlite': + $dsn = $this->catalogs[$catalog_id]['db_type'] . ':' . $this->catalogs[$catalog_id]['db_name']; + break; + } + + return $dsn; + } function __destruct() { -- 2.39.5