Advertisement
Guest User

Untitled

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