Пример #1
0
 private function __construct()
 {
     try {
         // assign PDO object to db variable
         self::$db = new PDO('mysql:host=' . $this->dbhost . ';dbname=' . dbname, $this->dbusername, $this->dbpassword);
         self::$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     } catch (PDOException $e) {
         // Output error - would normally log this to error file rather than output to user.
         echo "Connection Error: " . $e->getMessage();
     }
 }
 public static function close_connection()
 {
     self::$db = null;
 }
Пример #3
0
 public static function disconnect()
 {
     self::$db = null;
 }