sqlbuilder  - sqlbuilder

没人疼? 2019-12-25 10:10:17
[https://github.com/eehsiao/sqlbuilder](https://github.com/eehsiao/sqlbuilder) # sqlbuilder `sqlbuilder` is a simple sql query string builder sqlbuilder its recursive struct call, that you can easy to build sql string ex: dao.Select().From().Join().Where().Limit() ### SqlBuilder functions * build select : * Select(f ...string) * f is a fileds list of strings * Select("filed1", "filed2", "filed3") * Select(lib.Struce4QuerySlice(DaoStructType)...) * the library ref : [https://github.com/eehsiao/go-models-lib](https://github.com/eehsiao/go-models-lib) * Distinct(b bool) * its default in builder is set `false` * Top(i int) * only support mssql * From(t ...string) * t is table name * Where(c string) * c is condition, ex Where("field1=1 and filed2='b'") * WhereAnd(c ...string) * WhereOr(c ...string) * Limit(i ...int) * support 2 parms * only support mysql * Join(t string, c string) * t is table name * c is condition * InnerJoin(t string, c string) * LeftJoin(t string, c string) * RightJoin(t string, c string) * FullJoin(t string, c string) * GroupBy(f ...string) * f is a fileds list of strings * OrderBy(f ...string) * f is a fileds list of strings * OrderByAsc(f ...string) * OrderByDesc(f ...string) * Having(s string) * s is having condition string * BuildSelectSQL() * check and build sql string. * you can get sql string via `BuildedSQL()` * build update : * Set(s map[string]interface{}) * FromOne(t string) * reset the table for only one * BuildUpdateSQL() * check and build sql string. * you can get sql string via `BuildedSQL()` * build insert : * Into(t string) * set the insert table * Fields(f ...string) * f is a fileds list of strings * Values(v ...[]interface{}) * v is a values list of `interface{}` * BuildInsertSQL() * check and build sql string. * you can get sql string via `BuildedSQL()` * build delete : * BuildDeleteSQL() * check and build sql string. * you can get sql string via `BuildedSQL()` * common : * ClearBuilder() * reset builder * BuildedSQL() * return the builded sql string, if build success. * SetDbName(s string) * SetTbName(s string) * SwitchPanicToErrorLog(b bool) * PanicOrErrorLog(s string)
    公告

    《从零开始开发BBS》课程上线啦,快来跟着我一步步搭建属于你的BBS吧。

    课程地址:https://www.shiyanlou.com/courses/1436
    9折优惠邀请码: ZHwfIjb1

    该课程会带领大家一步步的了解并熟悉Go语言开发,如果你是一个Go语言初学者,或者正准备学习Go语言,那么这个课程非常适合你。如果你熟练掌握了本课程中的知识点,相信你就已经入门Go语言开发,并能胜任日常的开发工作了。