mirror of
https://gitee.com/johng/gf
synced 2026-07-03 11:51:04 +08:00
rename testing file names for package gdb
This commit is contained in:
@ -41,8 +41,7 @@ func (c *Core) convertValue(fieldValue []byte, fieldType string) interface{} {
|
||||
"smallint",
|
||||
"medium_int",
|
||||
"mediumint",
|
||||
"serial",
|
||||
"smallmoney":
|
||||
"serial":
|
||||
if gstr.ContainsI(fieldType, "unsigned") {
|
||||
gconv.Uint(string(fieldValue))
|
||||
}
|
||||
@ -65,7 +64,8 @@ func (c *Core) convertValue(fieldValue []byte, fieldType string) interface{} {
|
||||
"double",
|
||||
"decimal",
|
||||
"money",
|
||||
"numeric":
|
||||
"numeric",
|
||||
"smallmoney":
|
||||
return gconv.Float64(string(fieldValue))
|
||||
|
||||
case "bit":
|
||||
|
||||
40
database/gdb/gdb_z_example_test.go
Normal file
40
database/gdb/gdb_z_example_test.go
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright 2018 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package gdb_test
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/database/gdb"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func Example_transaction() {
|
||||
db.Transaction(func(tx *gdb.TX) error {
|
||||
// user
|
||||
result, err := tx.Insert("user", g.Map{
|
||||
"passport": "john",
|
||||
"password": "12345678",
|
||||
"nickname": "JohnGuo",
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// user_detail
|
||||
id, err := result.LastInsertId()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = tx.Insert("user_detail", g.Map{
|
||||
"uid": id,
|
||||
"site": "https://johng.cn",
|
||||
"true_name": "GuoQiang",
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user