Created
August 19, 2016 18:11
-
-
Save victorknust/f2cd660b8bf680a7b90f149e55e7134f to your computer and use it in GitHub Desktop.
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 $dsn, $username, $password; | |
| public function __construct($dsn, $username, $password) | |
| { | |
| $this->dsn = $dsn; | |
| $this->username = $username; | |
| $this->password = $password; | |
| $this->connect(); | |
| } | |
| private function connect() | |
| { | |
| $this->link = new PDO($this->dsn, $this->username, $this->password); | |
| } | |
| public function __sleep() | |
| { | |
| return array('dsn', 'username', 'password'); | |
| } | |
| public function __wakeup() | |
| { | |
| $this->connect(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment