mysql

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Db

type Db struct {
	DbConn *DbConnection
	// DbQuery  DbQuery
	Dbconfig *map[string]interface{}
}

func (*Db) Db

func (db *Db) Db(table string) *DbQuery

type DbConnection

type DbConnection struct {
	DB       *sql.DB
	DbPrefix string
	DbName   string
	DbConf   map[string]string
}

创建连接器

func (*DbConnection) Connt

func (DbConnection *DbConnection) Connt(cnt *map[string]string) error

构建连接

type DbQuery

type DbQuery struct {
	Wher string

	Joinn string

	DB     *sql.DB
	Rows   interface{}
	Row    interface{}
	Prefix string
	sync.RWMutex
	// contains filtered or unexported fields
}

构建查询器

func (*DbQuery) Alias

func (q *DbQuery) Alias(alias string) *DbQuery

func (*DbQuery) Builder

func (q *DbQuery) Builder(dbConnection *DbConnection)

func (*DbQuery) Count

func (q *DbQuery) Count() int

func (*DbQuery) CreateDBTx

func (q *DbQuery) CreateDBTx() (context.Context, *sql.Tx, error)

创建事务

func (*DbQuery) Del

func (q *DbQuery) Del() (sql.Result, error)

func (*DbQuery) Exec

func (q *DbQuery) Exec(sql string, args ...interface{}) (sql.Result, error)

func (*DbQuery) Field

func (q *DbQuery) Field(field string) *DbQuery

func (*DbQuery) Find

func (q *DbQuery) Find() (map[string]interface{}, error)

func (*DbQuery) GetRow

func (q *DbQuery) GetRow(query *sql.Rows) map[string]interface{}

func (*DbQuery) GetRows

func (q *DbQuery) GetRows(query *sql.Rows) []map[string]interface{}

func (*DbQuery) Group

func (q *DbQuery) Group(group string) *DbQuery

func (*DbQuery) Having

func (q *DbQuery) Having(h string, v interface{}) *DbQuery

func (*DbQuery) In

func (q *DbQuery) In(in string, v []interface{}) *DbQuery

func (*DbQuery) Join

func (q *DbQuery) Join(jType string, table string, on string) *DbQuery

涉及线程安全,改用字符串

func (*DbQuery) Limit

func (q *DbQuery) Limit(limit string) *DbQuery

func (*DbQuery) Or

func (q *DbQuery) Or(or string, v ...interface{}) *DbQuery

func (*DbQuery) OrIn

func (q *DbQuery) OrIn(in string, v []interface{}) *DbQuery

func (*DbQuery) Order

func (q *DbQuery) Order(order string) *DbQuery

func (*DbQuery) Query

func (q *DbQuery) Query(sql string, args ...interface{}) ([]map[string]interface{}, error)

func (*DbQuery) Save

func (q *DbQuery) Save(save map[string]interface{}) (sql.Result, error)

func (*DbQuery) Select

func (q *DbQuery) Select() ([]map[string]interface{}, error)

func (*DbQuery) SelectSql

func (q *DbQuery) SelectSql() string

func (*DbQuery) Size

func (q *DbQuery) Size(page int, size int) *DbQuery

func (*DbQuery) Table

func (q *DbQuery) Table(table string) *DbQuery

func (*DbQuery) TxSave

func (q *DbQuery) TxSave(ctx context.Context, tx *sql.Tx, save map[string]interface{}) (sql.Result, error)

事务写入

func (*DbQuery) TxUpdate

func (q *DbQuery) TxUpdate(ctx context.Context, tx *sql.Tx, update map[string]interface{}, where ...interface{}) (sql.Result, error)

事务更新

func (*DbQuery) Update

func (q *DbQuery) Update(update map[string]interface{}) (sql.Result, error)

func (*DbQuery) Value added in v1.0.8

func (q *DbQuery) Value(key string) (interface{}, error)

func (*DbQuery) Where

func (q *DbQuery) Where(wher string, v ...interface{}) *DbQuery

Jump to

Keyboard shortcuts

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