Guest User

Untitled

a guest
Jun 21st, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <?php
  2.  
  3. class Database
  4. {
  5. private static $_dbUser = 'root';
  6. private static $_dbPass = '';
  7. private static $_dbDB = 'filestatus';
  8. private static $_dbHost = 'localhost';
  9. private static $_connection = null;
  10.  
  11. /**
  12. * Constructor
  13. * prevents new Object creation
  14. */
  15.  
  16. private function __construct(){}
  17.  
  18. /**
  19. * Get Database connection
  20. *
  21. * @return Mysqli
  22. */
  23.  
  24. public static function getConnection() {
  25. if (self::$_connection===null)
  26. {
  27. self::$_connection = new mysqli(self::$_dbHost, self::$_dbUser, self::$_dbPass, self::$_dbDB);
  28.  
  29. if (self::$_connection -> connect_error)
  30. {
  31. die('Connect Error: ' . self::$_connection->connect_error);
  32. }
  33. }
  34. return self::$_connection;
  35. }
  36. }
Add Comment
Please, Sign In to add comment