Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Lazy_PDO
- {
- private $pdo;
- private $dsn, $username, $password, $options;
- public function __construct($dsn, $username, $password, $options) {
- $this->dsn = $dsn;
- $this->username = $username;
- $this->password = $password;
- $this->options = $options;
- }
- public function openConnection() {
- $this->pdo = new PDO($this->dsn, $this->username, $this->password, $this->options);
- }
- public function closeConnection() {
- unset($this->pdo);
- }
- public function __call($func, $args) {
- if ( is_null($this->pdo) ) {
- $this->openConnection();
- }
- return $this->pdo->$func($args);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement