This commit is contained in:
learnmore2019
2019-02-14 11:49:35 +08:00
2 changed files with 26 additions and 36 deletions

View File

@@ -284,6 +284,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()