34 lines
702 B
PHP
34 lines
702 B
PHP
<?php
|
|
class Database
|
|
{
|
|
static $dbName = 'dbditsco_bersyukur';
|
|
static $dbHost = 'localhost';
|
|
static $dbUsername = 'dbditsco_bersyukur';
|
|
static $dbUserPassword = 'Bersyukur_123_123_';
|
|
|
|
static $cont = null;
|
|
|
|
public function __construct()
|
|
{
|
|
die('Init function is not allowed');
|
|
}
|
|
|
|
public static function connect()
|
|
{
|
|
// One connection through whole application
|
|
if (null == self::$cont) {
|
|
try {
|
|
self::$cont = new PDO("mysql:host=" . self::$dbHost . ";" . "dbname=" . self::$dbName, self::$dbUsername, self::$dbUserPassword);
|
|
} catch (PDOException $e) {
|
|
die($e->getMessage());
|
|
}
|
|
}
|
|
return self::$cont;
|
|
}
|
|
|
|
public static function disconnect()
|
|
{
|
|
self::$cont = null;
|
|
}
|
|
}
|