host = getenv('DB_HOST') ?: 'localhost'; $this->user = getenv('DB_USER') ?: 'spota_informatika'; $this->pass = getenv('DB_PASSWORD') ?: 'Eud!}ZML3HVO'; $this->db = getenv('DB_KONSULTASI') ?: 'spota_konsultasi'; $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); if (!$con) { die('Could not connect to database!'); } else { $this->myconn = $con; } return $this->myconn; } 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 close() { $this->myconn = null; } 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; } }