aboutsummaryrefslogtreecommitdiffstats
path: root/MainDb.php
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2011-09-26 11:07:39 +0300
committerFilipp Lepalaan <filipp@mac.com>2011-09-26 11:07:39 +0300
commit0be64fe1aea8c49c6b6f08c0b70aa494a8b5e0a9 (patch)
tree46041ca804233460d77d0f21d38670ecbab5bfcc /MainDb.php
parentb09b087d04915923b1eb497439e5f0ba81c2ff69 (diff)
downloadmain-0be64fe1aea8c49c6b6f08c0b70aa494a8b5e0a9.tar.gz
main-0be64fe1aea8c49c6b6f08c0b70aa494a8b5e0a9.tar.bz2
main-0be64fe1aea8c49c6b6f08c0b70aa494a8b5e0a9.zip
Preliminary PostgreSQL support
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);
+
}
////