mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
improve perameter parsing for ghttp.Server
This commit is contained in:
34
.example/database/gdb/mysql/gdb_update_field.go
Normal file
34
.example/database/gdb/mysql/gdb_update_field.go
Normal file
@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"github.com/gogf/gf/os/gfile"
|
||||
|
||||
"github.com/gogf/gf/encoding/gjson"
|
||||
"github.com/gogf/gf/frame/g"
|
||||
)
|
||||
|
||||
func main() {
|
||||
db := g.DB()
|
||||
table := "medicine_clinics_upload_yinchuan"
|
||||
list, err := db.Table(table).All()
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
panic(err)
|
||||
}
|
||||
content := ""
|
||||
for _, item := range list {
|
||||
if j, err := gjson.DecodeToJson(item["upload_data"].String()); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
s, _ := j.ToJsonIndentString()
|
||||
content += item["id"].String() + "\t" + item["medicine_clinic_id"].String() + "\t"
|
||||
content += s
|
||||
content += "\n\n"
|
||||
//if _, err := db.Table(table).Data("data_decode", s).Where("id", item["id"].Int()).Update(); err != nil {
|
||||
// panic(err)
|
||||
//}
|
||||
}
|
||||
}
|
||||
gfile.PutContents("/Users/john/Temp/medicine_clinics_upload_yinchuan.txt", content)
|
||||
}
|
||||
@ -8,7 +8,6 @@ import (
|
||||
|
||||
func main() {
|
||||
db := g.DB()
|
||||
// 开启调试模式,以便于记录所有执行的SQL
|
||||
db.SetDebug(true)
|
||||
|
||||
r, e := db.Table("test").Where("id IN (?)", []interface{}{1, 2}).All()
|
||||
|
||||
Reference in New Issue
Block a user