fix primary Model
This commit is contained in:
parent
95ad2e1d6a
commit
788f224629
@ -5,17 +5,17 @@ final class Model
|
||||
private static $conn = null;
|
||||
|
||||
public static function get(){
|
||||
if($conn === null){
|
||||
init();
|
||||
if(self::$conn === null){
|
||||
self::init();
|
||||
}
|
||||
return $conn;
|
||||
return self::$conn;
|
||||
}
|
||||
|
||||
private static function init(){
|
||||
$PDO_URI = sprintf("mysql:host=%s;dbname=%s", $_ENV["DB_HOST"], $_ENV["DB_DBNAME"]);
|
||||
|
||||
try{
|
||||
$conn = new PDO($PDO_URI, $_ENV["DB_USER"], $_ENV["DB_PASSWORD"]);
|
||||
self::$conn = new PDO($PDO_URI, $_ENV["DB_USERNAME"], $_ENV["DB_PASSWORD"]);
|
||||
}catch(PDOException $e){
|
||||
die("Connection to the database failed");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user