mysql

package
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

* @Author: lisheng * @Date: 2022-10-10 23:46:08 * @LastEditTime: 2023-01-06 14:16:09 * @LastEditors: lisheng * @Description: mysql驱动管理,支持管理多个Mysql数据库连接 * @FilePath: /jf-go-kit/database/mysql/mysql.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDBEngnine

func CreateDBEngnine(user string, pwd string, addr string, port int, db string) *gorm.DB

*

  • @description: 创建数据库引擎
  • @param {string} user
  • @param {string} pwd
  • @param {string} addr
  • @param {int} port
  • @param {string} db
  • @return {*}
  • @author: liqiyuWorks

func DeleteRecordByCond

func DeleteRecordByCond(engineName string, tableName string, cond string, objPtr interface{}) (affectedRows int64, err error)

*

  • @description: D - Where 删除 根据条件查询
  • @param {string} tableName
  • @param {string} cond
  • @param {interface{}} objPtr
  • @return {*}
  • @author: liqiyuWorks

func FindRecordsByCond

func FindRecordsByCond(engineName string, tableName string, cond string, resultSlicePtr interface{}) error

*

  • @description: R - Where 多条数据查询 根据条件查询
  • @param {string} tableName
  • @param {string} cond
  • @param {string} condValue
  • @param {int} page
  • @param {int} pageSize
  • @param {interface{}} resultSlicePtr
  • @return {*}
  • @author: liqiyuWorks

func InitMysqlManager

func InitMysqlManager() func() error

*

  • @description: 初始化mysqlManager
  • @return {*}
  • @author: liqiyuWorks

func InsertRecord

func InsertRecord(engineName string, tableName string, objPtr interface{}) (affectedRows int64, err error)

*

  • @description: C - 插入数据 ---- 亲测 gorm的插入有问题
  • @param {string} tableName
  • @param {string} cond
  • @param {interface{}} objPtr
  • @return {*}
  • @author: liqiyuWorks

func QueryRecordByCond

func QueryRecordByCond(engineName string, tableName string, cond string, resultSlicePtr interface{}) error

*

  • @description: R - Where 单条数据查询 根据条件查询
  • @param {string} engineName
  • @param {string} tableName
  • @param {string} cond
  • @param {interface{}} resultSlicePtr
  • @return {*}
  • @author: liqiyuWorks

func RegisterTable

func RegisterTable(engineName string, tableObj interface{})

*

  • @description: mysql 自动注册表
  • @param {string} engineName
  • @param {interface{}} tableObj
  • @return {*}
  • @author: liqiyuWorks

func UpdateRecordByCond

func UpdateRecordByCond(engineName string, tableName string, cond string, fieldMap map[string]interface{}) (affectedRows int64, err error)

*

  • @description: U - Where 更新 根据条件查询
  • @param {string} tableName
  • @param {string} cond
  • @param {map[string]interface{}} fieldMap
  • @return {*}
  • @author: liqiyuWorks

Types

type MysqlManager

type MysqlManager struct {
	EngineMap map[string]*gorm.DB
}
var (
	GMysqlManager *MysqlManager = new(MysqlManager)
)

Jump to

Keyboard shortcuts

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