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
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.

4
db.php
View file

@ -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);

View file

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