diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b19eae8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+sites/default/files
+sites/default/settings.php
+.htaccess
diff --git a/pgsql-fix.patch b/pgsql-fix.patch
new file mode 100644
index 0000000..e69de29
diff --git a/sites/all/modules/project_issue_file_review/client/review/db/pgsql.inc b/sites/all/modules/project_issue_file_review/client/review/db/pgsql.inc
index e4c4074..50dd6b7 100644
--- a/sites/all/modules/project_issue_file_review/client/review/db/pgsql.inc
+++ b/sites/all/modules/project_issue_file_review/client/review/db/pgsql.inc
@@ -13,7 +13,27 @@
  */
 class pifr_client_db_interface_pgsql implements pifr_client_db_interface {
 
-  function get_information() {
+  // Connection to the checked out database.
+  protected $pdo;
+
+  // Connection to the postgreSQL database.
+  // Sudo connection for creating/droping databases.
+  protected $sudo_pdo;
+
+  public function __construct() {
+    $info = $this->get_information();
+    $this->sudo_conn = new PDO('pgsql:dbname=postgres;host=' . $info['host'], $info['username'], $info['password']);
+  }
+
+  protected function pg_conn() {
+    $info = $this->get_information();
+    if (!$this->pdo) {
+      $this->pdo = new PDO('pgsql:dbname=' . $info['name'] . ';host=' . $info['host'], $info['username'], $info['password']);
+    }
+    return $this->pdo;
+  }
+
+  public function get_information() {
     global $db_url;
 
     $url = parse_url($db_url['pifr_checkout']);
@@ -22,44 +42,43 @@ class pifr_client_db_interface_pgsql implements pifr_client_db_interface {
     $db['username'] = urldecode($url['user']);
     $db['password'] = urldecode($url['pass']);
     $db['host'] = urldecode($url['host']);
-    $db['port'] = urldecode($url['port']);
     return $db;
   }
 
   public function create_database() {
     global $db_url;
     $database = substr(parse_url($db_url['pifr_checkout'], PHP_URL_PATH), 1);
-    return (bool) db_query('CREATE DATABASE "%s"', $database);
+    return $this->sudo_conn->query('CREATE DATABASE "' . $database . '"');
   }
 
   public function drop_database() {
     global $db_url;
     $database = substr(parse_url($db_url['pifr_checkout'], PHP_URL_PATH), 1);
-    return (bool) db_query('DROP DATABASE "%s"', $database);
+    return $this->sudo_conn->query('DROP DATABASE "' . $database . '"');
   }
 
   public function set_variable($name, $value) {
-    if (db_set_active('pifr_checkout')) {
-      $status = db_query("REPLACE INTO {variable} (name, value)
-                VALUES ('%s', '%s')", $name, serialize($value));
-      $status = $status && db_query('TRUNCATE TABLE cache');
-      db_set_active();
-      return $status;
-    }
-    return FALSE;
+    $this->query("DELETE FROM {variable} WHERE name = ?", array($name));
+    $status = $this->query("INSERT INTO {variable} (name, value) VALUES (?, ?)", array($name, serialize($value)));
+    $this->query('TRUNCATE TABLE {cache}');
+    return $status;
   }
 
-  public function query($sql) {
-    if (db_set_active('pifr_checkout')) {
-      $result = @db_query($sql);
-      $rows = array();
-      while ($row = db_fetch_array($result)) {
-        $rows[] = $row;
+  public function query($sql, $args = array()) {
+    try {
+      if (empty($args)) {
+        $rs = $this->pg_conn()->query(db_prefix_tables($sql));
+      }
+      else {
+        $rs = $this->pg_conn()
+          ->prepare(db_prefix_tables($sql))
+          ->execute($args);
       }
-      db_set_active();
-      return $rows;
+      return is_object($rs) ? $rs->fetchAll() : $rs;
+    }
+    catch (Exception $e) {
+      return FALSE;
     }
-    return FALSE;
   }
 
   public function import($file) {
@@ -72,3 +91,4 @@ class pifr_client_db_interface_pgsql implements pifr_client_db_interface {
     return FALSE;
   }
 }
+
