summaryrefslogtreecommitdiffstats
path: root/web/lib/DB.class.php
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2017-02-26 10:30:16 +0100
committerLukas Fleischer <lfleischer@archlinux.org>2017-02-26 10:30:16 +0100
commit69f7eb115a0a48d4d2808708bcfef9eaf292f64c (patch)
treee8e4ac633b88099b6836ba3f637b0ab2b1d6a472 /web/lib/DB.class.php
parentfdd932ff8d5e5899cfeae9a8b29011fa2cf9d439 (diff)
parent5fd417d70154470d145c83a4b60693c8d877b016 (diff)
downloadaur-69f7eb115a0a48d4d2808708bcfef9eaf292f64c.tar.gz
aur-69f7eb115a0a48d4d2808708bcfef9eaf292f64c.tar.xz
Merge branch 'master' into maint
Diffstat (limited to 'web/lib/DB.class.php')
-rw-r--r--web/lib/DB.class.php24
1 files changed, 17 insertions, 7 deletions
diff --git a/web/lib/DB.class.php b/web/lib/DB.class.php
index b538e0d3..dfdbbf96 100644
--- a/web/lib/DB.class.php
+++ b/web/lib/DB.class.php
@@ -17,20 +17,30 @@ class DB {
public static function connect() {
if (self::$dbh === null) {
try {
- $dsn_prefix = config_get('database', 'dsn_prefix');
+ $backend = config_get('database', 'backend');
$host = config_get('database', 'host');
$socket = config_get('database', 'socket');
$name = config_get('database', 'name');
$user = config_get('database', 'user');
$password = config_get('database', 'password');
- $dsn = $dsn_prefix .
- ':host=' . $host .
- ';unix_socket=' . $socket .
- ';dbname=' . $name;
+ if ($backend == "mysql") {
+ $dsn = $backend .
+ ':host=' . $host .
+ ';unix_socket=' . $socket .
+ ';dbname=' . $name;
+
+ self::$dbh = new PDO($dsn, $user, $password);
+ self::$dbh->exec("SET NAMES 'utf8' COLLATE 'utf8_general_ci';");
+ } else if ($backend == "sqlite") {
+ $dsn = $backend .
+ ":" . $name;
+
+ self::$dbh = new PDO($dsn, null, null);
+ } else {
+ die("Error - " . $backend . " is not supported by aurweb");
+ }
- self::$dbh = new PDO($dsn, $user, $password);
- self::$dbh->exec("SET NAMES 'utf8' COLLATE 'utf8_general_ci';");
} catch (PDOException $e) {
die('Error - Could not connect to AUR database');
}