Guest User

Untitled

a guest
Aug 28th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. <?php
  2.  
  3. class Conn implements IConn
  4. {
  5. private $host;
  6. private $dbname;
  7. private $user;
  8. private $pass;
  9.  
  10. public function __construct($host, $dbname, $user, $pass)
  11. {
  12. $this->host = $host;
  13. $this->$dbname = $dbname;
  14. $this->user = $user;
  15. $this->$pass = $pass;
  16. }
  17.  
  18. public function connect()
  19. {
  20. try {
  21. return new \PDO(
  22. "mysql:host={$this->host};dbname={$this->dbname}",
  23. $this->user,
  24. $this->pass
  25. );
  26. } catch (\PDOException $e) {
  27. echo "Error!!!<br>Message: " . $e->getMessage() . "<br>Code: " . $e->getCode();
  28. exit;
  29. }
  30. }
  31. }
Add Comment
Please, Sign In to add comment