Add database type option
This commit is contained in:
parent
97c75691ce
commit
ea95c63e18
3 changed files with 6 additions and 4 deletions
|
@ -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
4
db.php
|
@ -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);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
$type = 'pgsql';
|
||||||
$host = 'localhost';
|
$host = 'localhost';
|
||||||
$dbname = '';
|
$dbname = '';
|
||||||
$username = '';
|
$username = '';
|
||||||
|
|
Loading…
Add table
Reference in a new issue