Created
          December 5, 2016 15:44 
        
      - 
      
 - 
        
Save igoralves1/008c59d32bf7a3957404dd3a57ad7a92 to your computer and use it in GitHub Desktop.  
    db Class ... constructor
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | //This is a constructor that will return a handle to deal with a connection to the database MySQL | |
| public function __construct() { | |
| $this->dsn = "xxxxxxxx"; | |
| $this->username = "xxxxxxx"; | |
| $this->password = "xxxxx"; | |
| $this->db = "xxxxx"; | |
| try { | |
| $this->conn = new PDO("mysql:host=$this->dsn; dbname=$this->db", $this->username, $this->password); | |
| $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
| }// End of try | |
| catch(PDOException $e){ | |
| echo $e->getMessage(); | |
| $this->conn = null; | |
| die(); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment