aboutsummaryrefslogtreecommitdiffstats
path: root/MainDb.php
diff options
context:
space:
mode:
Diffstat (limited to 'MainDb.php')
-rw-r--r--MainDb.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/MainDb.php b/MainDb.php
index 8c05aac..e1e76eb 100644
--- a/MainDb.php
+++ b/MainDb.php
@@ -40,9 +40,18 @@ class MainDb
// always use UTF-8?
self::$instance->query('SET NAMES utf8');
break;
+ case 'pgsql':
+ self::$instance = new PDO(
+ "{$c['db.driver']}:host={$c['db.host']};dbname={$c['db.name']}",
+ $c['db.username'], $c['db.password'], array(PDO::ATTR_PERSISTENT => true)
+ );
+ break;
case 'sqlite':
self::$instance = new PDO('sqlite:'.$c['db.path']);
break;
+ default:
+ exit('Unknown db driver: ' . $c['db.driver']);
+ break;
}
} catch (PDOException $e) {
@@ -166,8 +175,10 @@ class MainDb
if (is_array($data)) {
$args = $data;
}
- $stmt = self::query($sql, $args) or exit(MainApp::error('Error executing query '.$sql));
+
+ $stmt = self::query($sql, $args) or exit(MainApp::error('Error executing query: '.$sql));
return $stmt->fetchAll(PDO::FETCH_ASSOC);
+
}
////