diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-07 14:38:58 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-07 14:38:58 +0200 |
commit | 68857cea8c08aab54c632d63f4526d0bb16f80d4 (patch) | |
tree | 897739759347c81a8c33e32b5020819cbada8c7e /inc | |
parent | bc1ee8524e0769ad37e3c4c02cfe96d2f60e52f6 (diff) | |
download | wallabag-68857cea8c08aab54c632d63f4526d0bb16f80d4.tar.gz wallabag-68857cea8c08aab54c632d63f4526d0bb16f80d4.tar.zst wallabag-68857cea8c08aab54c632d63f4526d0bb16f80d4.zip |
setup of storage
Diffstat (limited to 'inc')
-rw-r--r-- | inc/poche/Database.class.php | 33 | ||||
-rw-r--r-- | inc/poche/config.inc.php | 9 |
2 files changed, 25 insertions, 17 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 | ||
diff --git a/inc/poche/config.inc.php b/inc/poche/config.inc.php index 834b18ea..ef2f699d 100644 --- a/inc/poche/config.inc.php +++ b/inc/poche/config.inc.php | |||
@@ -8,6 +8,14 @@ | |||
8 | * @license http://www.wtfpl.net/ see COPYING file | 8 | * @license http://www.wtfpl.net/ see COPYING file |
9 | */ | 9 | */ |
10 | 10 | ||
11 | # storage | ||
12 | define ('STORAGE','postgres'); # postgres, mysql, sqlite | ||
13 | define ('STORAGE_SERVER', 'localhost'); # leave blank for sqlite | ||
14 | define ('STORAGE_DB', 'poche'); # only for postgres & mysql | ||
15 | define ('STORAGE_SQLITE', './db/poche.sqlite'); | ||
16 | define ('STORAGE_USER', 'postgres'); # leave blank for sqlite | ||
17 | define ('STORAGE_PASSWORD', 'postgres'); # leave blank for sqlite | ||
18 | |||
11 | define ('POCHE_VERSION', '1.0-beta'); | 19 | define ('POCHE_VERSION', '1.0-beta'); |
12 | define ('MODE_DEMO', FALSE); | 20 | define ('MODE_DEMO', FALSE); |
13 | define ('DEBUG_POCHE', TRUE); | 21 | define ('DEBUG_POCHE', TRUE); |
@@ -24,7 +32,6 @@ define ('CACHE', './cache'); | |||
24 | define ('LANG', 'en_EN.UTF8'); | 32 | define ('LANG', 'en_EN.UTF8'); |
25 | define ('PAGINATION', '10'); | 33 | define ('PAGINATION', '10'); |
26 | define ('THEME', 'light'); | 34 | define ('THEME', 'light'); |
27 | define ('STORAGE','postgres'); # postgres, mysql, sqlite | ||
28 | 35 | ||
29 | # /!\ Be careful if you change the lines below /!\ | 36 | # /!\ Be careful if you change the lines below /!\ |
30 | require_once './inc/poche/User.class.php'; | 37 | require_once './inc/poche/User.class.php'; |