Advertisement
Guest User

Untitled

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