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

这个提交存在于:
Sébastien Lucas 2013-11-25 17:10:43 +01:00
父节点 26f5b36563
当前提交 4d9b3a4925
共有 3 个文件被更改,包括 17 次插入3 次删除

查看文件

@ -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;