From 57a2f9374a87cb18d3a995005955f00ca6b44e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=81=AB=E7=BA=BF=E5=85=94?= Date: Thu, 13 Oct 2022 12:00:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BD=BF=E7=94=A8paginator?= =?UTF-8?q?=E6=97=B6=EF=BC=8Climit=E6=9C=AA=E6=B8=85=E9=99=A4=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=A4=8D=E5=90=88Count=E5=8A=9F=E8=83=BD=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- orm_query.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/orm_query.go b/orm_query.go index 0a293e6..4f486f5 100644 --- a/orm_query.go +++ b/orm_query.go @@ -74,6 +74,7 @@ func (dba *Orm) Counts(count_fileds ...string) (int64, error) { if dba.group == "" { return dba.Count(count_fileds...) } else { + dba.limit = 0 dba.fields = []string{"count(DISTINCT " + dba.group + ") as count"} // 构建sql sqls, args, err := dba.BuildSql() @@ -84,6 +85,7 @@ func (dba *Orm) Counts(count_fileds ...string) (int64, error) { if err != nil { return 0, err } + //fmt.Println(dba.LastSql()) if len(total_number) < 1 { return 0, err } @@ -533,7 +535,6 @@ func (dba *Orm) Paginator(page ...int) (res Paginate, err error) { dba.GetISession().GetIBinder().SetBindName(tabname) dba.GetISession().GetIBinder().SetBindPrefix(prefix) dba.where = where - count, err2 := dba.Counts() if err2 != nil { err = err2