|
@@ -356,6 +356,11 @@ func (m *Mysql) UpdateByTx(tx *sql.Tx, tableName string, query, update map[strin
|
|
|
|
|
|
//批量更新
|
|
|
func (m *Mysql) UpdateBath(tableName string, fields []string, array [][]interface{}) {
|
|
|
+ m.UpdateBathByTx(nil, tableName, fields, array)
|
|
|
+}
|
|
|
+
|
|
|
+//带事务的批量更新
|
|
|
+func (m *Mysql) UpdateBathByTx(tx *sql.Tx, tableName string, fields []string, array [][]interface{}) int64 {
|
|
|
ws := []string{}
|
|
|
args := []interface{}{}
|
|
|
ids := []interface{}{}
|
|
@@ -381,7 +386,7 @@ func (m *Mysql) UpdateBath(tableName string, fields []string, array [][]interfac
|
|
|
}
|
|
|
args = append(args, ids...)
|
|
|
sql := fmt.Sprintf(`update %s set %s where %s in (%s)`, tableName, strings.Join(sql_appends, ","), fields[0], strings.Join(ws, ","))
|
|
|
- m.UpdateOrDeleteBySql(sql, args...)
|
|
|
+ return m.UpdateOrDeleteBySqlByTx(tx, sql, args...)
|
|
|
}
|
|
|
|
|
|
//删除
|