Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. class Connection {
  2.  
  3. public $host = 'localhost';
  4. public $dbname = 'usodecontas';
  5. public $username = 'root';
  6. public $password = 'abc123';
  7.  
  8. public function conectar() {
  9. try {
  10.  
  11. $conn = new PDO("mysql:host={$this->host};dbname={$this->dbname}", $this->username, $this->password);
  12.  
  13. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  14. return $conn;
  15.  
  16. } catch (PDOException $e) {
  17. echo $e->getMessage();
  18. }
  19.  
  20. }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement