Skip to content

Commit

Permalink
Count语句修复
Browse files Browse the repository at this point in the history
  • Loading branch information
tobycroft committed Sep 19, 2022
1 parent e08a25d commit e682e19
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion orm_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,11 @@ func (dba *Orm) Paginator(page ...int) (res Paginate, err error) {
dba.GetISession().GetIBinder().SetBindPrefix(prefix)
dba.where = where

dba.fields = []string{"count(distinct " + dba.group + ") as count"}
if dba.group != "" {
dba.fields = []string{"count(distinct " + dba.group + ") as count"}
} else {
dba.fields = []string{"count(*) as count"}
}

// 构建sql
sqls, args, err_sql := dba.BuildSql()
Expand All @@ -535,6 +539,7 @@ func (dba *Orm) Paginator(page ...int) (res Paginate, err error) {
return
}
count := int64(0)
//fmt.Println(sqls)
total_number, err := dba.Query(`SELECT count(0) as count from(`+sqls+`) as counts`, args...)
if len(total_number) < 1 {
return
Expand Down

0 comments on commit e682e19

Please sign in to comment.