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