Fix the redirect in case the database is not found. I also handle better the case were no file are actually found. Thanks to At Libitum. fix #116
This commit is contained in:
parent
26f5b36563
commit
4d9b3a4925
3 changed files with 17 additions and 3 deletions
14
base.php
14
base.php
|
@ -889,15 +889,23 @@ abstract class Base
|
|||
public static function getDbFileName ($database = NULL) {
|
||||
return self::getDbDirectory ($database) .'metadata.db';
|
||||
}
|
||||
|
||||
private static function error () {
|
||||
header("location: checkconfig.php?err=1");
|
||||
exit();
|
||||
}
|
||||
|
||||
public static function getDb ($database = NULL) {
|
||||
global $config;
|
||||
if (is_null (self::$db)) {
|
||||
try {
|
||||
self::$db = new PDO('sqlite:'. self::getDbFileName ($database));
|
||||
if (file_exists (self::getDbFileName ($database))) {
|
||||
self::$db = new PDO('sqlite:'. self::getDbFileName ($database));
|
||||
} else {
|
||||
self::error ();
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
header("location: checkconfig.php?err=1");
|
||||
exit();
|
||||
self::error ();
|
||||
}
|
||||
}
|
||||
return self::$db;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue