Align Steven DB connection with deploy env
This commit is contained in:
@@ -2,13 +2,27 @@
|
||||
|
||||
class createCon
|
||||
{
|
||||
public $host = 'localhost';
|
||||
public $user = 'spota_informatika';
|
||||
public $pass = 'Eud!}ZML3HVO';
|
||||
public $db = 'spota_spotadb';
|
||||
public $host;
|
||||
public $user;
|
||||
public $pass;
|
||||
public $db;
|
||||
public $dbSpota;
|
||||
public $dbBio;
|
||||
public $dbDosen;
|
||||
|
||||
public $myconn;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->host = getenv('DB_HOST') ?: 'localhost';
|
||||
$this->user = getenv('DB_USER') ?: 'spota_informatika';
|
||||
$this->pass = getenv('DB_PASSWORD') ?: 'Eud!}ZML3HVO';
|
||||
$this->db = getenv('DB_SPOTA') ?: getenv('DB_NAME') ?: 'spota_spotadb';
|
||||
$this->dbSpota = getenv('DB_SPOTA') ?: getenv('DB_NAME') ?: 'spota_spotadb';
|
||||
$this->dbBio = getenv('DB_BIO') ?: 'enda_daftarmhs';
|
||||
$this->dbDosen = getenv('DB_DOSEN') ?: 'enda_dosen';
|
||||
}
|
||||
|
||||
public function connect()
|
||||
{
|
||||
$con = new PDO('mysql:host='.$this->host.';dbname='.$this->db, $this->user, $this->pass);
|
||||
@@ -25,4 +39,50 @@ class createCon
|
||||
{
|
||||
$this->myconn = null;
|
||||
}
|
||||
|
||||
public function connectSpota()
|
||||
{
|
||||
$con = new PDO('mysql:host='.$this->host.';dbname='.$this->dbSpota, $this->user, $this->pass);
|
||||
if (!$con) {
|
||||
die('Could not connect to database!');
|
||||
} else {
|
||||
$this->myconn = $con;
|
||||
}
|
||||
|
||||
return $this->myconn;
|
||||
}
|
||||
|
||||
public function connectDbBio()
|
||||
{
|
||||
$con = new PDO('mysql:host='.$this->host.';dbname='.$this->dbBio, $this->user, $this->pass);
|
||||
if (!$con) {
|
||||
die('Could not connect to database!');
|
||||
} else {
|
||||
$this->myconn = $con;
|
||||
}
|
||||
|
||||
return $this->myconn;
|
||||
}
|
||||
|
||||
public function closeDbBio()
|
||||
{
|
||||
$this->myconn = null;
|
||||
}
|
||||
|
||||
public function connectDbDosen()
|
||||
{
|
||||
$con = new PDO('mysql:host='.$this->host.';dbname='.$this->dbDosen, $this->user, $this->pass);
|
||||
if (!$con) {
|
||||
die('Could not connect to database!');
|
||||
} else {
|
||||
$this->myconn = $con;
|
||||
}
|
||||
|
||||
return $this->myconn;
|
||||
}
|
||||
|
||||
public function closeDbDosen()
|
||||
{
|
||||
$this->myconn = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user