Advertisement
Guest User

database

a guest
Nov 21st, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. <?php
  2.  
  3. class Database
  4. {
  5. private static $dbHost = "localhost";
  6. private static $dbName = "burger_code";
  7. private static $dbUsername = "root";
  8. private static $dbUserpassword = "root";
  9.  
  10. private static $connection = null;
  11.  
  12. public static function connect()
  13. {
  14. if(self::$connection == null)
  15. {
  16. try
  17. {
  18. self::$connection = new PDO("mysql:host=" . self::$dbHost . ";dbname=" . self::$dbName , self::$dbUsername, self::$dbUserpassword);
  19. }
  20. catch(PDOException $e)
  21. {
  22. die($e->getMessage());
  23. }
  24. }
  25. return self::$connection;
  26. }
  27.  
  28. public static function disconnect()
  29. {
  30. self::$connection = null;
  31. }
  32.  
  33. }
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement