Skip to content

Instantly share code, notes, and snippets.

@mpmont
Created October 6, 2012 21:51
Show Gist options
  • Save mpmont/3846287 to your computer and use it in GitHub Desktop.
Save mpmont/3846287 to your computer and use it in GitHub Desktop.
Sleep and wakeup
<?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