Guest User

Untitled

a guest
Sep 25th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. <?php
  2.  
  3. //exemple d'appel
  4. Database::getInstance();
  5.  
  6. class Database {
  7.  
  8. private static $instance;
  9.  
  10. private $pdo;
  11.  
  12. private $host;
  13.  
  14. private $dbName;
  15.  
  16. private $userName;
  17.  
  18. private $password;
  19.  
  20. public function __construct($host, $dbName, $userName, $password) {
  21. $this->host = $host;
  22. $this->dbName = $dbName;
  23. $this->userName = $userName;
  24. $this->password = $password;
  25. }
  26.  
  27. public static function getInstance() {
  28. if(static::$instance == null) {
  29. static::$instance = new Database($host, $dbName, $userName, $password);
  30. }
  31.  
  32. return static::$instance;
  33. }
  34. }
Add Comment
Please, Sign In to add comment