Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 253cad35ef | |||
| 47c8736f34 |
+15
-15
@@ -566,18 +566,18 @@ func (that *HoTimeDB) Query(query string, args ...interface{}) []Map {
|
|||||||
resl, err = db.Query(query, args...)
|
resl, err = db.Query(query, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err != nil && that.LastErr.GetError() != nil &&
|
||||||
|
that.LastErr.GetError().Error() == err.Error() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
that.LastErr.SetError(err)
|
that.LastErr.SetError(err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
if err = db.Ping(); err == nil {
|
if err = db.Ping(); err == nil {
|
||||||
return that.Query(query, args...)
|
return that.Query(query, args...)
|
||||||
} else {
|
|
||||||
|
|
||||||
err = that.InitDb()
|
|
||||||
that.LastErr.SetError(err)
|
|
||||||
if err == nil {
|
|
||||||
return that.Query(query, args...)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
that.LastErr.SetError(err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -607,20 +607,18 @@ func (that *HoTimeDB) Exec(query string, args ...interface{}) (sql.Result, *Erro
|
|||||||
resl, e = that.DB.Exec(query, args...)
|
resl, e = that.DB.Exec(query, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if e != nil && that.LastErr.GetError() != nil &&
|
||||||
|
that.LastErr.GetError().Error() == e.Error() {
|
||||||
|
return resl, that.LastErr
|
||||||
|
}
|
||||||
that.LastErr.SetError(e)
|
that.LastErr.SetError(e)
|
||||||
|
|
||||||
//判断是否连接断开了
|
//判断是否连接断开了
|
||||||
if e != nil {
|
if e != nil {
|
||||||
|
|
||||||
if e = that.DB.Ping(); e == nil {
|
if e = that.DB.Ping(); e == nil {
|
||||||
return that.Exec(query, args...)
|
return that.Exec(query, args...)
|
||||||
} else {
|
|
||||||
e = that.InitDb()
|
|
||||||
that.LastErr.SetError(e)
|
|
||||||
if e == nil {
|
|
||||||
return that.Exec(query, args...)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
that.LastErr.SetError(e)
|
||||||
return resl, that.LastErr
|
return resl, that.LastErr
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -667,11 +665,13 @@ func (that *HoTimeDB) Select(table string, qu ...interface{}) []Map {
|
|||||||
data := ObjToSlice(qu[intQs])
|
data := ObjToSlice(qu[intQs])
|
||||||
for i := 0; i < len(data); i++ {
|
for i := 0; i < len(data); i++ {
|
||||||
k := data.GetString(i)
|
k := data.GetString(i)
|
||||||
if strings.Contains(k, " AS ") {
|
if strings.Contains(k, " AS ") ||
|
||||||
|
strings.Contains(k, ".") {
|
||||||
|
|
||||||
query += " " + k + " "
|
query += " " + k + " "
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
query += " `" + k + "` "
|
query += " `" + k + "` "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user