コード例 #1
0
func QueryUserById(userId int64) *POIUser {
	var user *POIUser
	qb, _ := orm.NewQueryBuilder(libs.GetDBDriverName())
	qb.Select("id,nickname,avatar,gender,access_right,status,balance,phone,last_login_time").From("users").Where("id = ?")
	sql := qb.String()
	o := orm.NewOrm()
	err := o.Raw(sql, userId).QueryRow(&user)
	if err != nil {
		return nil
	}
	return user
}
コード例 #2
0
func QueryUsers(start, pageCount int) POIUsers {
	users := make(POIUsers, 0)
	qb, _ := orm.NewQueryBuilder(libs.GetDBDriverName())
	qb.Select("id,nickname,avatar,gender,access_right,status,balance,phone,last_login_time").
		From("users").OrderBy("id").Desc().Limit(pageCount).Offset(start)
	sql := qb.String()
	o := orm.NewOrm()
	_, err := o.Raw(sql).QueryRows(&users)
	if err != nil {
		return nil
	}
	return users
}