public static function getInstance() { try { if (!self::$_instance instanceof self) { self::$_instance = new self(); } return self::$_instance; } catch (PDOException $e) { die('Подключение не удалось: ' . $e->getMessage() . $e->errorInfo); } }
/** * Connect to the database and set the error mode to Exception. * @return void * @access public */ public function connectToDB() { try { $dns = 'mysql:host=' . self::$hostname . ';dbname=' . self::$dbname; self::$instance = new PDO($dns, self::$username, self::$password); self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->db = self::$instance; } catch (PDOException $e) { print "Error No <b> GEDM-1001 </b>"; die; } }