Advertisement
Guest User

dblogin

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