diff options
author | Filipp Lepalaan <filipp@mac.com> | 2011-09-26 11:07:39 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2011-09-26 11:07:39 +0300 |
commit | 0be64fe1aea8c49c6b6f08c0b70aa494a8b5e0a9 (patch) | |
tree | 46041ca804233460d77d0f21d38670ecbab5bfcc /MainDb.php | |
parent | b09b087d04915923b1eb497439e5f0ba81c2ff69 (diff) | |
download | main-0be64fe1aea8c49c6b6f08c0b70aa494a8b5e0a9.tar.gz main-0be64fe1aea8c49c6b6f08c0b70aa494a8b5e0a9.tar.bz2 main-0be64fe1aea8c49c6b6f08c0b70aa494a8b5e0a9.zip |
Preliminary PostgreSQL support
Diffstat (limited to 'MainDb.php')
-rw-r--r-- | MainDb.php | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -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); + } //// |