Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. <?php
  2. namespace Database;
  3.  
  4. use Database;
  5.  
  6. class Database
  7. {
  8. private $host = "";
  9. private $db_name = "";
  10. private $username = "";
  11. private $password = "";
  12. public $conn;
  13.  
  14. public function getConnection()
  15. {
  16.  
  17. $this->conn = null;
  18.  
  19. try {
  20. $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
  21. } catch (PDOException $exception) {
  22. echo "Connection error: " . $exception->getMessage();
  23. }
  24.  
  25. return $this->conn;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement