From ea95c63e1823437b97a7376d61ed1218900c5afa Mon Sep 17 00:00:00 2001 From: Gregory Trolliet Date: Wed, 25 Nov 2020 19:43:40 +0100 Subject: [PATCH] Add database type option --- README.md | 4 ++++ db.php | 4 +--- dbconfig_empty.php | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 38f676d..a76c7db 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ # SimpleWordsCloud This site allows to create simple words cloud, without any registrations. There is nothing stored on the server except the words. + +## Database +Database config option is set in the dbconfig.php file, +example is in dbconfig_empty.php. diff --git a/db.php b/db.php index 76489e9..d09a175 100644 --- a/db.php +++ b/db.php @@ -22,9 +22,7 @@ class DataBase public function init() { require_once 'dbconfig.php'; - $dsn = 'pgsql:dbname=' . $dbname - . ';host=' . $host - . ';port=' . $port; + $dsn = "$type:dbname=$dbname;host=$host;port=$port"; try { $this->db = new PDO($dsn, $username, $password); $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); diff --git a/dbconfig_empty.php b/dbconfig_empty.php index 9a4c838..d8a342e 100644 --- a/dbconfig_empty.php +++ b/dbconfig_empty.php @@ -1,5 +1,5 @@