From: Davide Franco Date: Fri, 15 Jul 2011 13:29:53 +0000 (+0200) Subject: bacula-web: Fixed bug in DSN construction for SQLite database support X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=57f882b0a875591bb58816da33291bdef181c3fd;p=bacula%2Fbacula bacula-web: Fixed bug in DSN construction for SQLite database support --- 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() {