mirror of
https://gitlab.com/ruany/litebans-php.git
synced 2025-05-24 08:52:45 +00:00
Add pgsql support
This commit is contained in:
parent
ad7b4b70de
commit
edea8056fa
@ -47,13 +47,19 @@ final class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($connect) {
|
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 {
|
try {
|
||||||
$this->conn = new PDO($dsn, $username, $password);
|
$this->conn = new PDO($dsn, $username, $password);
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
echo 'Connection failed: ' . $e->getMessage();
|
echo 'Connection failed: ' . $e->getMessage();
|
||||||
}
|
}
|
||||||
|
if ($driver === 'pgsql') {
|
||||||
|
$this->conn->query("SET NAMES 'UTF8';");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user