Browse Source

修改分页计算

master v0.3.1
guzeng 3 years ago
parent
commit
cb4b8fe26d
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      chain.go

+ 6
- 4
chain.go View File

@ -64,7 +64,9 @@ func (this *Query) Where(where string) *Query {
return this
}
func (this *Query) Wheres(wheres []string) *Query {
this.where = append(this.where, wheres...)
if len(wheres) > 0 {
this.where = append(this.where, wheres...)
}
return this
}
func (this *Query) WhereOr(where string) *Query {
@ -158,13 +160,13 @@ func (this *Query) QueryStmt() error {
if this.page > 0 || this.page_size > 0 {
if this.page < 0 {
this.page = 0
if this.page < 1 {
this.page = 1
}
if this.page_size < 1 {
this.page_size = 10
}
from := strconv.Itoa(this.page * this.page_size)
from := strconv.Itoa((this.page - 1) * this.page_size)
offset := strconv.Itoa(this.page_size)
if from != "" && offset != "" {
sql = helper.StringJoin(sql, " limit ", from, " , ", offset)


Loading…
Cancel
Save