Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. //This is a constructor that will return a handle to deal with a connection to the database MySQL
  2.  
  3. public function __construct() {
  4. $this->dsn = "xxxxxxxx";
  5. $this->username = "xxxxxxx";
  6. $this->password = "xxxxx";
  7. $this->db = "xxxxx";
  8.  
  9. try {
  10. $this->conn = new PDO("mysql:host=$this->dsn; dbname=$this->db", $this->username, $this->password);
  11. $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  12.  
  13. }// End of try
  14. catch(PDOException $e){
  15. echo $e->getMessage();
  16. $this->conn = null;
  17. die();
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement