// SELECT * FROM `user` WHERE `score`>60
Model("user").Where("score>?", 60).All()
// SELECT * FROM `user` WHERE `score`>60 LIMIT 1
Model("user").Where("score>?", 60).One()
// SELECT `name` FROM `user` WHERE `score`>60
Model("user").Fields("name").Where("score>?", 60).Array()
// SELECT `name` FROM `user` WHERE `uid`=1 LIMIT 1
Model("user").Fields("name").Where("uid", 1).Value()
// SELECT COUNT(1) FROM `user` WHERE `status` IN(1,2,3)
Model("user").Where("status", g.Slice{1,2,3}).Count()
3 Comments
zhl
有获取指定两列数据为键值对的方法吗?,结果类似[column1=>column2, column1=>column2...]
Justin
例子都是select * from table_name吗?不用考虑硬解析吗?
keepeye
没有Find*方法啊,提示
.FindAll undefined (type *gdb.Model has no field or method FindAll)
我装的是最新版的