未验证 提交 385391bf 编写于 作者: A astaxie 提交者: GitHub

Merge pull request #1092 from hjlarry/patch-1

Update 05.5.md
......@@ -218,12 +218,12 @@ type Tag struct {
func init() {
// 需要在init中注册定义的model
orm.RegisterModel(new(Userinfo),new(User), new(Profile), new(Tag))
orm.RegisterModel(new(Userinfo),new(User), new(Profile), new(Post), new(Tag))
}
```
>注意一点,beego orm针对驼峰命名会自动帮你转化成下划线字段,例如你定义了Struct名字为`UserInfo`,那么转化成底层实现的时候是`user_info`,字段命名也遵循该规则。
>注意一点,beego orm针对驼峰命名会自动帮你转化成下划线字段,例如你定义了struct名字为`UserInfo`,那么转化成底层实现的时候是`user_info`,字段命名也遵循该规则。
## 插入数据
下面的代码演示了如何插入一条记录,可以看到我们操作的是struct对象,而不是原生的sql语句,最后通过调用Insert接口将数据保存到数据库。
......@@ -287,7 +287,7 @@ o.Update(&user, "Name")
// o.Update(&user, "Field1", "Field2", ...)
```
//Where:用来设置条件,支持多个参数,第一个参数如果为整数,相当于调用了Where("主键=?",值)。
Where: 用来设置条件,支持多个参数,第一个参数如果为整数,相当于调用了Where("主键=?",值)。
## 查询数据
beego orm的查询接口比较灵活,具体使用请看下面的例子
......@@ -384,7 +384,7 @@ num, err := qs.Filter("User__Name", "slene").All(&posts)
## Group By和Having
## GroupBy和Having
针对有些应用需要用到group by的功能,beego orm也提供了一个简陋的实现
```Go
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册