Add database type option

This commit is contained in:
Gregory Trolliet 2020-11-25 19:43:40 +01:00
parent 97c75691ce
commit ea95c63e18
3 changed files with 6 additions and 4 deletions

View file

@ -1,3 +1,7 @@
# SimpleWordsCloud # SimpleWordsCloud
This site allows to create simple words cloud, without any registrations. This site allows to create simple words cloud, without any registrations.
There is nothing stored on the server except the words. 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.

4
db.php
View file

@ -22,9 +22,7 @@ class DataBase
public function init() public function init()
{ {
require_once 'dbconfig.php'; require_once 'dbconfig.php';
$dsn = 'pgsql:dbname=' . $dbname $dsn = "$type:dbname=$dbname;host=$host;port=$port";
. ';host=' . $host
. ';port=' . $port;
try { try {
$this->db = new PDO($dsn, $username, $password); $this->db = new PDO($dsn, $username, $password);
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

View file

@ -1,5 +1,5 @@
<?php <?php
$type = 'pgsql';
$host = 'localhost'; $host = 'localhost';
$dbname = ''; $dbname = '';
$username = ''; $username = '';