func (a *Select) GenSess(args ...interface{}) *xorm.Session { var s *xorm.Session = a.Orm.NewSession() s.IsAutoClose = true switch len(args) { case 2: alias, _ := args[1].(string) if args[0] == nil { s = s.Alias(alias) } else { s = s.Table(args[0]).Alias(alias) a.Table = args[0] } a.Alias = alias case 1: s = s.Table(args[0]) a.Table = args[0] default: if a.Table != nil { s = s.Table(a.Table) } if a.Alias != `` { s = s.Alias(a.Alias) } } s = s.Where(a.Condition, a.Params...).GroupBy(a.GroupBy) if a.Having != `` { s = s.Having(a.Having) } return s }
func (this *Model) Sess() *xorm.Session { // TransSession or Session ss, ok := this.transSession() if ok == false { var ss *xorm.Session = this.DB.NewSession() ss.IsAutoClose = true return ss } return ss }