diff options
Diffstat (limited to 'inc/poche/Database.class.php')
-rw-r--r-- | inc/poche/Database.class.php | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index a226b31e..034b1003 100644 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php | |||
@@ -9,24 +9,25 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | class Database { | 11 | class Database { |
12 | |||
13 | #postgresql | ||
14 | public static $db_path = 'pgsql:host=localhost;dbname=poche'; | ||
15 | public static $user = 'postgres'; | ||
16 | public static $password = 'postgres'; | ||
17 | #sqlite | ||
18 | // public static $db_path = 'sqlite:./db/poche.sqlite'; | ||
19 | // public static $user = ''; | ||
20 | // public static $password = ''; | ||
21 | #mysql | ||
22 | // public static $db_path = 'mysql:host=localhost;dbname=poche'; | ||
23 | // public static $user = 'root'; | ||
24 | // public static $password = 'root'; | ||
25 | |||
26 | var $handle; | 12 | var $handle; |
27 | 13 | ||
28 | function __construct() { | 14 | function __construct() |
29 | $this->handle = new PDO(self::$db_path, self::$user, self::$password); | 15 | { |
16 | switch (STORAGE) { | ||
17 | case 'sqlite': | ||
18 | $db_path = 'sqlite:' . STORAGE_SQLITE; | ||
19 | $this->handle = new PDO($db_path); | ||
20 | break; | ||
21 | case 'mysql': | ||
22 | $db_path = 'mysql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB; | ||
23 | $this->handle = new PDO($db_path, STORAGE_USER, STORAGE_PASSWORD); | ||
24 | break; | ||
25 | case 'postgres': | ||
26 | $db_path = 'pgsql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB; | ||
27 | $this->handle = new PDO($db_path, STORAGE_USER, STORAGE_PASSWORD); | ||
28 | break; | ||
29 | } | ||
30 | |||
30 | $this->handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | 31 | $this->handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
31 | } | 32 | } |
32 | 33 | ||