Singleton

PDO Singleton Class

the singleton design pattern allows you to have one and only one instance of a class/object. it is good for large, shared resources like databases. <?php /** @author Brian Danchilla @brief PDO singleton class */ class PDO_DBConnect { static $db ; private $dbh ; private function PDO_DBConnect () { $db_type = 'pgsql'; //ex) mysql, postgresql, oracle $db_name = 'myDatabase'; $user = 'brian' ; $password = 'myP@ssw0rd' ; $host = 'localhost' ; try {

Subscribe to RSS - Singleton