Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2.  
  3. class Database
  4. {
  5. private $hostname = 'DESKTOP-S3L4V04\SQLEXPRESS';
  6. private $port = '1433';
  7. private $dbname = 'ACCOUNT_DBF';
  8. private $username = 'DESKTOP-S3L4V04\Dylan';
  9. private $password = '';
  10. protected $db = NULL;
  11.  
  12. public function __construct()
  13. {
  14. $this->connect();
  15. }
  16.  
  17. public function connect()
  18. {
  19. try
  20. {
  21. echo 'bug';
  22. //$db = new PDO("sqlsrv:Server=" + $this->hostname + "," + $this->port + ";Database=" + $this->dbname, $this->username, $this->password);
  23. $db = new PDO("sqlsrv:Server=$this->hostname;Database=$this->dbname", $this->username, $this->password);
  24. echo 'Connexion acceptée';
  25. }
  26. catch(Exception $e)
  27. {
  28. echo $e->getMessage();
  29. }
  30. }
  31.  
  32. public function close()
  33. {
  34. $db = NULL;
  35. }
  36.  
  37. public function isAlive()
  38. {
  39. if($db)
  40. return TRUE;
  41. else
  42. return FALSE;
  43. }
  44. };
  45.  
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement