public static function get_instance($db_config) { if (self::$_db instanceof UbntMysql) { } else { $db = new mysqli($db_config['host'], $db_config['user'], $db_config['pass'], $db_config['name'], $db_config['port']); if ($db->connect_error) { $db = new mysqli($db_config['host'], $db_config['user'], $db_config['pass'], $db_config['name'], $db_config['port']); if ($db->connect_error) { throw new Exception('数据库维护中,请稍后再试', $db->errno); } } $charset = isset($db_config['char']) ? $db_config['char'] : 'utf8'; if ($charset) { $db->set_charset($charset); } self::$mysql = $db; self::$_db = new self(); } return self::$_db; }
/* 微信 开发者中心->服务器配置 Token值 */ define('WECHAT_TOKEN', ''); /* 是否加密 */ define('WECHAT_ENCODING_ENABLE', false); /* 加密用的EncodingAESKey */ define('WECHAT_ENCODING_AES_KEY', ''); /* 高级调用功能的app id */ define('WECHAT_APP_ID', ''); /* 高级调用功能的app secret */ define('WECHAT_APP_SECRET', ''); /* 微信消息和欢迎内容 */ define('WEIXIN_AUTH_MESSAGE', ''); //当用户发送此内容才能获取返回 define('WEIXIN_WELCOME_MESSAGE', ''); //关注后的欢迎内容 //-----------------------------------微信------------------------------------------------------ //-----------------------------------MySQL---------------------------------------------------- /* 配置mysql */ define('DB_HOST', 'localhost'); define('DB_USERNAME', ''); define('DB_PASSWORD', ''); //数据库密码 define('DB_DBNAME', ''); //数据库库名 define('DB_PORT', '3306'); define('WEIXIN_TABLE', ''); //微信表名 //-----------------------------------MySQL---------------------------------------------------- $config = array('host' => DB_HOST, 'user' => DB_USERNAME, 'pass' => DB_PASSWORD, 'name' => DB_DBNAME, 'port' => DB_PORT); $mysql = UbntMysql::get_instance($config);