diff --git a/chain.go b/chain.go index 96737f7..5b724c6 100644 --- a/chain.go +++ b/chain.go @@ -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)