<?php
/**
* Project Agnostic DbH.inc.php with MySQLi
* @author nml
* @copyright (c) 2018, nml
* @license http://www.fsf.org/licensing/ GPLv3
*/
require_once 'DbP.inc.php';
class DbH extends DbP {
private static $dbh;
private function __construct() {}
public static function getDbH() {
if (empty(self::$dbh)) {
try {
self::$dbh = new mysqli(DbP::DBHOST, DbP::DBUSER, DbP::USERPWD, DbP::DB);
} catch(mysqli_sql_exception $e) {
die(sprintf("<p>Connect failed for following reason: <br/>%s: %s</p>\n",
$e->getCode(), $e->getMessage()));
}
}
return self::$dbh;
}
}