fix数据插入更新获取返回id和影响数

This commit is contained in:
TsMask
2023-09-05 19:25:39 +08:00
parent ffe4545386
commit d782595d8c
6 changed files with 100 additions and 49 deletions

View File

@@ -1,6 +1,7 @@
package datasource
import (
"database/sql"
"regexp"
"ems.agt/lib/dborm"
@@ -33,7 +34,7 @@ func RawDB(source string, sql string, parameters []any) ([]map[string]any, error
}
// ExecDB 原生执行语句
func ExecDB(source string, sql string, parameters []any) (int64, error) {
func ExecDB(source string, sql string, parameters []any) (sql.Result, error) {
// 数据源
db := DefaultDB()
@@ -42,8 +43,7 @@ func ExecDB(source string, sql string, parameters []any) (int64, error) {
// 执行结果
res, err := db.Exec(append([]any{fmtSql}, parameters...)...)
if err != nil {
return 0, err
return nil, err
}
affected, err := res.RowsAffected()
return affected, err
return res, err
}