Advertisement
Guest User

Untitled

a guest
Dec 25th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. <?php
  2.  
  3. class Connection
  4. {
  5. protected $link;
  6. private $dsn, $username, $password;
  7.  
  8. public function __construct($dsn, $username, $password)
  9. {
  10. $this->dsn = $dsn;
  11. $this->username = $username;
  12. $this->password = $password;
  13. $this->connect();
  14. }
  15.  
  16. private function connect()
  17. {
  18. $this->link = new PDO($this->dsn, $this->username, $this->password);
  19. }
  20.  
  21. public function __sleep()
  22. {
  23. return array('dsn', 'username', 'password');
  24. }
  25.  
  26. public function __wakeup()
  27. {
  28. $this->connect();
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement