修改集群bug

数据库模块空指针问题
This commit is contained in:
boyce
2019-02-14 11:44:50 +08:00
parent fc5ce025a3
commit 273c410801
2 changed files with 26 additions and 36 deletions

View File

@@ -283,6 +283,11 @@ func (slf *DBModule) SyncQuery(query string, args ...interface{}) SyncDBResult {
// Exec ...
func (slf *DBModule) Exec(query string, args ...interface{}) DBResult {
ret := DBResult{}
if slf.db == nil {
ret.Err = fmt.Errorf("cannot connect database!")
return ret
}
res, err := slf.db.Exec(query, args...)
ret.Err = err
ret.LastInsertID, _ = res.LastInsertId()