mysql

package
v0.0.0-...-c3ec36b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

package gosql mysql工具包..引用"github.com/go-sql-driver/mysql"

Index

Constants

View Source
const (
	DuplicateErrorCode = 1062 //字段重复
	PRIMARY            = "primary"
)

Variables

View Source
var DuplicateField = errors.New("字段重复")
View Source
var SQLEmptyChange = errors.New("数据无变化")

Functions

func Connect

func Connect(host, username, password, db string, other ...string) (db.SQL, error)

链接mysql数据库,其中other参数代表链接字符串附加的配置信息 其中other="loc=Local&multiStatements=true"

func ExecResultHasError

func ExecResultHasError(execresult db.ExecResult, reportZeroChange bool, param ...map[string]string) error

执行结果是否有错误

func GetDuplicateField

func GetDuplicateField(errmsg string) string

获取重复字段

func SelectSQL

func SelectSQL(obj interface{}, tablename ...string) *bytes.Buffer

SelectSQL 获取对象

func SetSQL

func SetSQL(obj interface{}) (string, []interface{})

SetSQL 转换成插入语句

func Update

func Update(table string, obj interface{}) (string, []interface{}, error)

Update 更新数据

func WhereIN

func WhereIN(field string, values string, args []interface{}, bs *bytes.Buffer, char ...string) (*bytes.Buffer, []interface{})

拼接 where in 条件,field要查询的字段名称以及拼接条件,value表示in中的字段值多个值按char[默认逗号]分割,args表示参数集合 返回拼接结果和参数集合,eg: whereIN("AND material_code", "xxx,xxxxx", args, bs)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL