1 Star 0 Fork 7

bits-chen/go-sqlbuilder

forked from 艾润物联/go-sqlbuilder 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
where.go 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
Yoojia Chen 提交于 2018-05-24 22:49 . Refactoring package
package gsb
import (
"bytes"
)
//
// Author: 陈永佳 chenyongjia@parkingwang.com, yoojiachen@gmail.com
//
type WhereBuilder struct {
buffer *bytes.Buffer
conditions SQLStatement
}
func (slf *WhereBuilder) Compile() string {
slf.buffer.WriteString(slf.conditions.Compile())
return slf.buffer.String()
}
func (slf *WhereBuilder) GetSQL() string {
slf.buffer.WriteString(slf.conditions.Compile())
return endOfSQL(slf.buffer)
}
func (slf *WhereBuilder) Limit(limit int) *LimitBuilder {
return newLimit(slf, limit)
}
func (slf *WhereBuilder) OrderBy(columns ...string) *OrderByBuilder {
return newOrderBy(slf, columns...)
}
func (slf *WhereBuilder) GroupBy(columns ...string) *GroupByBuilder {
return newGroupBy(slf, columns...)
}
func (slf *WhereBuilder) Execute(prepare SQLPrepare) *Executor {
return newExecute(slf.GetSQL(), prepare)
}
//
func newWhere(preStatement SQLStatement, conditions SQLStatement) *WhereBuilder {
wb := &WhereBuilder{
buffer: new(bytes.Buffer),
conditions: conditions,
}
if nil != preStatement {
wb.buffer.WriteString(preStatement.Compile())
}
wb.buffer.WriteString(" WHERE ")
return wb
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/bitschen/go-sqlbuilder.git
git@gitee.com:bitschen/go-sqlbuilder.git
bitschen
go-sqlbuilder
go-sqlbuilder
master

搜索帮助