add a field(LastInsertId) in scope to getLastInsertId
This commit is contained in:
parent
836fb2c19d
commit
4ddf5a8da9
@ -128,6 +128,8 @@ func createCallback(scope *Scope) {
|
||||
if result, err := scope.SQLDB().Exec(scope.SQL, scope.SQLVars...); scope.Err(err) == nil {
|
||||
// set rows affected count
|
||||
scope.db.RowsAffected, _ = result.RowsAffected()
|
||||
// set lastInsertId
|
||||
scope.db.LastInsertId, _ = result.LastInsertId()
|
||||
|
||||
// set primary value to primary field
|
||||
if primaryField != nil && primaryField.IsBlank {
|
||||
|
1
main.go
1
main.go
@ -17,6 +17,7 @@ type DB struct {
|
||||
Value interface{}
|
||||
Error error
|
||||
RowsAffected int64
|
||||
LastInsertId int64
|
||||
|
||||
// single db
|
||||
db SQLCommon
|
||||
|
Loading…
x
Reference in New Issue
Block a user