public static function getInstance() { // Only one instance of this class should ever exist. // $db_instance will hold a refernce to this instance and we create and return it here. // (This is why the constructor has been made private below. It should not be invoked externally) if (DB_MySQL_PDO::$db_instance === NULL) { DB_MySQL_PDO::$db_instance = new DB_MySQL_PDO(); try { DB_MySQL_PDO::$db_instance->pdo = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_DBASE, DB_USER, DB_PASS); DB_MySQL_PDO::$db_instance->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); } catch (PDOException $e) { //throw new RestException(501, 'MySQL: ' . $e->getMessage()); throw new DatabaseErrorException($e->getMessage()); } } return DB_MySQL_PDO::$db_instance; }
function __construct($in = NULL) { $this->dp = DB_MySQL_PDO::getInstance(); }