duckbrain/src/Libs/Database.php
2020-03-07 23:37:19 -04:00

20 lines
384 B
PHP

<?php
namespace Libs;
class Database {
static private $db;
private function __construct() {}
static public function getConnection() {
if (!isset(self::$db)) {
self::$db = new \mysqli(dbhost, dbuser, dbpass, dbname);
if (self::$db->connect_errno) {
exit('No se ha podido conectar a la base de datos.');
}
}
return self::$db;
}
}
?>