Created
March 5, 2016 04:06
-
-
Save goldalworming/f4535d4f92d5930afa03 to your computer and use it in GitHub Desktop.
use where in beego
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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