工具
This commit is contained in:
+6
-1
@@ -33,7 +33,7 @@ func (this *Application) Run(router Router) {
|
||||
//this.Port = port
|
||||
this.Port = this.Config.GetString("port")
|
||||
|
||||
if this.connectDbFunc != nil {
|
||||
if this.connectDbFunc != nil && this.Db.DB.Ping() != nil {
|
||||
this.Db.SetConnect(this.connectDbFunc)
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ func (this *Application) Run(router Router) {
|
||||
//启动实例
|
||||
func (this *Application) SetConnectDB(connect func(err ...*Error) *sql.DB) {
|
||||
this.connectDbFunc = connect
|
||||
this.Db.SetConnect(this.connectDbFunc)
|
||||
}
|
||||
|
||||
//设置配置文件路径全路径或者相对路径
|
||||
@@ -70,6 +71,10 @@ func (this *Application) SetSession(short CacheIns, Long CacheIns) {
|
||||
func (this *Application) SetDefault(connect func(err ...*Error) *sql.DB) {
|
||||
this.SetConfig()
|
||||
this.connectDbFunc = connect
|
||||
if this.connectDbFunc!=nil{
|
||||
this.Db.SetConnect(this.connectDbFunc)
|
||||
}
|
||||
|
||||
//防止手动设置缓存误伤
|
||||
if this.CacheIns == nil {
|
||||
this.SetCache(CacheIns(&CacheMemory{}))
|
||||
|
||||
Reference in New Issue
Block a user