fix issue in batch number for package gdb

This commit is contained in:
jflyfox
2021-01-22 23:21:29 +08:00
parent ab9d7ed509
commit f579c724c6
2 changed files with 25 additions and 1 deletions

View File

@ -0,0 +1,24 @@
package main
import (
"fmt"
"github.com/gogf/gf/frame/g"
)
func main() {
db := g.DB()
db.SetDebug(true)
list := make(g.List, 0)
for i := 0; i < 100; i++ {
list = append(list, g.Map{
"name": fmt.Sprintf(`name_%d`, i),
})
}
r, e := db.Table("user").Data(list).Batch(2).Insert()
if e != nil {
panic(e)
}
if r != nil {
fmt.Println(r.LastInsertId())
}
}