插入
o := orm.NewOrm()

user := UserInfo{Username: "zhangsan1", Password: "123456"}
id, err := o.Insert(&user)
c.Ctx.WriteString(fmt.Sprintf("操作数据库id=%d err:%v",id,err))
fmt.Println("\n")
user = UserInfo{Username: "lisi", Password: "654321"}
id, err= o.Insert(&user)
c.Ctx.WriteString(fmt.Sprintf("操作数据库id=%d err:%v",id,err))

 

修改
user := UserInfo{Username: "list", Password: "1234"}
user.Id = 13
o := orm.NewOrm()
o.Update(&user)
c.Ctx.WriteString(fmt.Sprintf("操作数据库user:%v", user))

 

读取
o := orm.NewOrm()
user := UserInfo{Id: 13}
o.Read(&user)
c.Ctx.WriteString(fmt.Sprintf("操作数据库user:%v", user))

 

删除
o := orm.NewOrm()
user := UserInfo{Id: 13}
o.Delete(&user)
c.Ctx.WriteString(fmt.Sprintf("操作数据库user:%v", user))