Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
92
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. class Connection
  3. {
  4. protected $link;
  5. private $dsn, $username, $password;
  6.  
  7. public function __construct($dsn, $username, $password)
  8. {
  9. $this->dsn = $dsn;
  10. $this->username = $username;
  11. $this->password = $password;
  12. $this->connect();
  13. }
  14.  
  15. private function connect()
  16. {
  17. $this->link = new PDO($this->dsn, $this->username, $this->password);
  18. }
  19.  
  20. public function __sleep()
  21. {
  22. return array('dsn', 'username', 'password');
  23. }
  24.  
  25. public function __wakeup()
  26. {
  27. $this->connect();
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement