Created
October 6, 2012 21:51
-
-
Save mpmont/3846287 to your computer and use it in GitHub Desktop.
Sleep and wakeup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Connection | |
{ | |
protected $link; | |
private $server, $username, $password, $db; | |
public function __construct($server, $username, $password, $db) | |
{ | |
$this->server = $server; | |
$this->username = $username; | |
$this->password = $password; | |
$this->db = $db; | |
$this->connect(); | |
} | |
private function connect() | |
{ | |
$this->link = mysql_connect($this->server, $this->username, $this->password); | |
mysql_select_db($this->db, $this->link); | |
} | |
public function __sleep() | |
{ | |
return array('server', 'username', 'password', 'db'); | |
} | |
public function __wakeup() | |
{ | |
$this->connect(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment