TKK_E32210823/absensi/webapi/config/database.php

21 lines
693 B
PHP

<?php
class Database {
private $host = "localhost";
private $database_name = "labandroid_logabsencam";
private $username = "root";
private $password = "";
public $conn;
public function getConnection(){
$this->conn = null;
try{
$this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->database_name, $this->username, $this->password);
$this->conn->exec("set names utf8");
}catch(PDOException $exception){
echo "Database could not be connected: " . $exception->getMessage();
}
return $this->conn;
}
}
?>