conn = new PDO( 'mysql:host=' . getenv('MYSQL_HOST') . ';dbname=' . getenv('MYSQL_DATABASE') . ';port=' . getenv('MYSQL_PORT'), getenv('MYSQL_USER'), getenv('MYSQL_PASSWORD') ); } catch (PDOException $e) { die('Connection failed: ' . $e->getMessage()); } } public static function getInstance() { if (!self::$instance) { self::$instance = new database(); } return self::$instance; } public function getConnection() { return $this-> conn; } }