public function __construct() { if (self::$db == null) { self::$db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); self::$db->set_charset("utf8"); if (self::$db->connect_errno) { die(DB_CONNECTION_ERROR); } } }
public function __construct() { if (self::$db == null) { self::$db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); self::$db->set_charset("utf8"); if (self::$db->connect_errno) { die("Cannot connect to database"); } } }
public function __construct() { if (self::$db == null) { self::$db = new mysqli($host, $user, $password, $db_name); self::$db->set_charset('utf8'); } if (self::$db->connect_errorno) { die('Connect failed:' . $db->connect_error); } }
public static function initDb() { self::$db = new PDO(PDO_DSN, DB_USER, DB_PASS); self::$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }