public function __construct() { try { self::$PDOConnection = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PASS); self::$PDOConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { if ($e->getCode() == 0) { //connection failed code $this->showErrorPage("Connection to database failed. ", $e); } } }