From 0be64fe1aea8c49c6b6f08c0b70aa494a8b5e0a9 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Mon, 26 Sep 2011 11:07:39 +0300 Subject: Preliminary PostgreSQL support --- MainDb.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'MainDb.php') 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); + } //// -- cgit v1.2.3