使用原生sql查询

package test_orm

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
)

type TestOrmChap05Controller struct {
	beego.Controller
}

type ToStruct struct {
	Total string
	Page string
}


func (t *TestOrmChap05Controller) Get()  {
	o := orm.NewOrm()



	//r := o.Raw("insert into article VALUES(id,?,?,?)","知了课堂","zhiliao",6)
	//ret,err := r.Exec()
	//fmt.Println(err)
	//fmt.Println(ret.LastInsertId())
	//fmt.Println(ret.RowsAffected())


	// Exec方法,只能执行增删改,不能查
	//r := o.Raw("insert into article VALUES(id,?,?,?)","知了课堂测试","zhiliao",9)
	//r := o.Raw("UPDATE article set title=? WHERE id =?","知了课堂测试11111",19)
	//r := o.Raw("DELETE FROM article WHERE id = ?",18)
	//ret,_ := r.Exec()
	//fmt.Println(ret.LastInsertId())
	//fmt.Println(ret.RowsAffected())

	// QueryRow:查询一条数据

	// 不建议使用
	//var id int
	//var title stri
上一篇:【论文笔记】Deformable DETR:使用稀疏Attention实现目标检测


下一篇:通读BadCode