From edea8056fabe6512afb3d94a0750eb09905c9dc2 Mon Sep 17 00:00:00 2001 From: Ruan Date: Sun, 23 Aug 2015 07:35:34 +0200 Subject: [PATCH] Add pgsql support --- includes/settings.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/settings.php b/includes/settings.php index 9be6edc..371a85e 100644 --- a/includes/settings.php +++ b/includes/settings.php @@ -47,13 +47,19 @@ final class Settings { } if ($connect) { - $dsn = "$driver:dbname=$database;host=$host;port=$port;charset=utf8"; + $dsn = "$driver:dbname=$database;host=$host;port=$port"; + if ($driver === 'mysql') { + $dsn .= ';charset=utf8'; + } try { $this->conn = new PDO($dsn, $username, $password); } catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage(); } + if ($driver === 'pgsql') { + $this->conn->query("SET NAMES 'UTF8';"); + } } } }