Esempio n. 1
0
 public static function connect($sDb = null, $sHost = null, $sUser = null, $sPass = null)
 {
     self::disconnect();
     $sHost = $sHost ? $sHost : M::DB_HOST();
     $sUser = $sUser ? $sUser : M::DB_USER();
     $sPass = $sPass ? $sPass : M::DB_PASSWORD();
     $sDb = $sDb ? $sDb : M::DB_NAME();
     self::$_oDb = new mysqli($sHost, $sUser, $sPass, $sDb);
     self::$_oDb->set_charset('utf8');
     if (self::$_oDb->connect_errno) {
         switch (self::$_oDb->connect_errno) {
             case 2002:
                 throw new Exception('Mysql error: MYSQL SERVER IS DOWN');
             default:
                 throw new Exception('Mysql error: (' . self::$_oDb->connect_errno . ') ' . self::$_oDb->connect_error);
         }
     }
 }