qesydb

package module
v0.0.0-...-010e2b4 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: Apache-2.0 Imports: 8 Imported by: 4

README

QesyDb

A simple MySQL go class library !

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OpenLog         int           = 0
	MaxOpenConns    int           = 600
	MaxIdleConns    int           = 600
	ConnMaxLifetime time.Duration = time.Minute * 3
)

OpenLog 是否记录日志

View Source
var Db *sql.DB

Db 指针

Functions

func Begin

func Begin() (*sql.Tx, error)

Begin 开始事务

func Commit

func Commit(tx *sql.Tx) error

Commit 事务提交

func Connect

func Connect(connStr string) error

Connect is a method with a sql.

func Delete

func Delete(TableName string, Cond map[string]string) (sql.Result, error)

Delete 删除

func DeleteTx

func DeleteTx(TableName string, Cond map[string]string, m Model) (sql.Result, error)

DeleteTx 删除

func GetLastInsertID

func GetLastInsertID(result sql.Result) (int64, error)

GetLastInsertID 获取最后插入的ID

func GetRowsAffected

func GetRowsAffected(result sql.Result) (int64, error)

GetRowsAffected 获取受影响行数

func Insert

func Insert(TableName string, InsertArr map[string]string) (sql.Result, error)

Insert 插入一条

func InsertBatch

func InsertBatch(TableName string, InsertArr []map[string]string) (sql.Result, error)

InsertBatch 批量插入

func InsertBatchTx

func InsertBatchTx(TableName string, InsertArr []map[string]string, m Model) (sql.Result, error)

InsertBatchTx 批量插入

func InsertTx

func InsertTx(TableName string, InsertArr map[string]string, m Model) (sql.Result, error)

InsertTx 插入

func Replace

func Replace(TableName string, InsertArr map[string]string) (sql.Result, error)

Replace 替换

func ReplaceBatch

func ReplaceBatch(TableName string, InsertArr []map[string]string) (sql.Result, error)

Replace 批量替换

func ReplaceBatchTx

func ReplaceBatchTx(TableName string, InsertArr []map[string]string, m Model) (sql.Result, error)

Replace 批量替换

func ReplaceTx

func ReplaceTx(TableName string, InsertArr map[string]string, m Model) (sql.Result, error)

ReplaceTx 替换

func Rollback

func Rollback(tx *sql.Tx) error

Rollback 事务回滚

func Select

func Select(TableName string, Cond map[string]string) ([]map[string]string, error)

Select 查询

func SelectOne

func SelectOne(TableName string, Cond map[string]string) (map[string]string, error)

SelectOne 查询一条

func SelectOneTx

func SelectOneTx(TableName string, Cond map[string]string, m Model) (map[string]string, error)

SelectOneTx 查询一条

func SelectTx

func SelectTx(TableName string, Cond map[string]string, m Model) ([]map[string]string, error)

SelectTx 查询

func Update

func Update(TableName string, UpdateArr map[string]string, Cond map[string]string) (sql.Result, error)

Update 修改

func UpdateTx

func UpdateTx(TableName string, UpdateArr map[string]string, Cond map[string]string, m Model) (sql.Result, error)

UpdateTx 修改

Types

type Model

type Model struct {
	Cond      interface{}
	Insert    map[string]string
	InsertArr []map[string]string
	Update    map[string]string
	Field     string
	Table     string
	Index     string
	Limit     interface{}
	Sort      string
	GroupBy   string
	IsDeug    int
	Tx        *sql.Tx
	Scan      []interface{}
}

Model 结构

func ModelGet

func ModelGet() Model

ModelGet 获取一个Model

func (*Model) Clean

func (m *Model) Clean()

Clean 清楚orm

func (*Model) Debug

func (m *Model) Debug(sql string)

Debug 打印调试

func (*Model) Exec

func (m *Model) Exec(sqlStr string) (sql.Result, error)

Exec 执行SQL语句

func (*Model) ExecDelete

func (m *Model) ExecDelete() (sql.Result, error)

ExecDelete 删除

func (*Model) ExecInsert

func (m *Model) ExecInsert() (sql.Result, error)

ExecInsert 添加

func (*Model) ExecInsertBatch

func (m *Model) ExecInsertBatch() (sql.Result, error)

ExecInsertBatch 批量添加 (预计要删除)

func (*Model) ExecReplace

func (m *Model) ExecReplace() (sql.Result, error)

ExecReplace 替换

func (*Model) ExecReplaceBatch

func (m *Model) ExecReplaceBatch() (sql.Result, error)

ExecReplace 替换

func (*Model) ExecSelect

func (m *Model) ExecSelect() ([]map[string]string, error)

ExecSelect 执行查询 返回一个 切片MAP

func (*Model) ExecSelectIndex

func (m *Model) ExecSelectIndex() (map[string]map[string]string, error)

ExecSelectIndex 返回一个MAP

func (*Model) ExecSelectOne

func (m *Model) ExecSelectOne() (map[string]string, error)

ExecSelectOne 只查询一条

func (*Model) ExecUpdate

func (m *Model) ExecUpdate() (sql.Result, error)

ExecUpdate 修改

func (*Model) Query

func (m *Model) Query(sqlStr string) ([]map[string]string, error)

Query 查询SQL,返回一个 切片MAP; SqlStr : SQL语句

func (*Model) SetDebug

func (m *Model) SetDebug(Debug int) *Model

SetDebug 设置是否打开调试

func (*Model) SetField

func (m *Model) SetField(Field string) *Model

SetField 设置查询字段

func (*Model) SetGroupBy

func (m *Model) SetGroupBy(GroupBy string) *Model

SetGroupBy 设置排序字段

func (*Model) SetIndex

func (m *Model) SetIndex(Index string) *Model

SetIndex 设置索引字段

func (*Model) SetInsert

func (m *Model) SetInsert(InsertMap map[string]string) *Model

SetInsert 设置插入字段

func (*Model) SetInsertArr

func (m *Model) SetInsertArr(InsertMapArr []map[string]string) *Model

SetInsertArr 设置批量插入字段

func (*Model) SetLimit

func (m *Model) SetLimit(Limit interface{}) *Model

SetLimit 设置查询数量

func (*Model) SetSort

func (m *Model) SetSort(Sort string) *Model

SetSort 设置排序字段

func (*Model) SetTable

func (m *Model) SetTable(Str string) *Model

SetTable 选择数据表

func (*Model) SetUpdate

func (m *Model) SetUpdate(UpdateMap map[string]string) *Model

SetUpdate 设置修改字段

func (*Model) SetWhere

func (m *Model) SetWhere(Cond interface{}) *Model

SetWhere 设置条件

Jump to

Keyboard shortcuts

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