Skip to content

Instantly share code, notes, and snippets.

@goldalworming
Created March 5, 2016 04:06
Show Gist options
  • Save goldalworming/f4535d4f92d5930afa03 to your computer and use it in GitHub Desktop.
Save goldalworming/f4535d4f92d5930afa03 to your computer and use it in GitHub Desktop.
use where in beego
func (c *RegisterController) Tes() {
res := struct{
Success bool
Rows []*models.User
Total int64
}{}
ids := []int{1, 2, 3}
o := orm.NewOrm()
arrstr := make([]string,len(ids))
for i := 0; i < len(ids); i++ {arrstr[i] = "?"}
strtpl := strings.Join(arrstr,",")
o.Raw("SELECT username FROM user WHERE kode IN ("+strtpl+")", ids).QueryRows(&res.Rows)
res.Success = true
c.Data["json"] = res
c.ServeJSON()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment