dbquery

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

*

  • DB transaction

Index

Constants

This section is empty.

Variables

View Source
var DB *sql.DB

Functions

func CloseConn

func CloseConn() error

func CloseStmt

func CloseStmt(stmt *sql.Stmt) error

func Connect

func Connect(DBHOST, DBUSER, DBPWD, DBNAME, DBPORT string, conns ...int) error

func Delete

func Delete(dbName, table string, data map[string]string, del_count ...string) (int64, error)

*

  • 删除数据
  • @param count 删除数量

func DoQuery

func DoQuery(args ...interface{}) ([]map[string]string, error)

func GetCount

func GetCount(dbName, table string, where map[string]string, args ...string) (total int)

*

  • 查询总数
  • 2020/06/04

func GetData

func GetData(dbName, table string, title string, where map[string]string, limit map[string]string) (int, map[string]string, error)

*

  • 查找一条记录
  • @param dbName 数据表名
  • @param title 查询字段名

func GetDataByStmt

func GetDataByStmt(dbName string, table string, title string, where []string, valuelist []interface{}, limit map[string]string) (map[string]string, error)

*

  • 使用db prepare方式查询单条数据
  • @param dbName
  • @param title 查询的字段名
  • @param where 查询条件
  • @param valuelist 查询的条件值
  • @param limit 查询排序
  • GZ
  • 2020/05/19

func GetDbTableName

func GetDbTableName(dbName, table string) string

func GetInfo

func GetInfo(dbName, table string, title string, where map[string]string) (map[string]string, error)

func GetJoinListByStmt

func GetJoinListByStmt(dbName string, tableA, tableA_alias string, tableB, tableB_alias string, join_type, join_on string, title string, where []string, valuelist []interface{}, limit map[string]string, page ...int) ([]map[string]string, error)

*

  • 联表查询
  • @param dbName
  • @param tableA 表一
  • @param tableA_alias 表一别名
  • @param tableB 表二
  • @param tableB_alias 表二别名
  • @param join 联表方式
  • @param join_on 联表字段
  • @param title 查询的字段名
  • @param where 查询条件
  • @param valuelist 查询的条件值
  • @param limit 查询排序
  • @param page 查询范围,可传两个值 pageNum,pageSize
  • GZ
  • 2020/11/23

func GetList

func GetList(dbName, table string, title string, where map[string]string, limit map[string]string) ([]map[string]string, error)

*

  • 查询列表
  • 2018/04/19

func GetListByStmt

func GetListByStmt(dbName string, table string, title string, where []string, valuelist []interface{}, limit map[string]string, page ...int) ([]map[string]string, error)

*

  • 使用db prepare方式查询列表
  • @param dbName
  • @param title 查询的字段名
  • @param where 查询条件
  • @param valuelist 查询的条件值
  • @param limit 查询排序
  • @param page 查询范围,可传两个值 pageNum,pageSize
  • GZ
  • 2020/05/19

func GetTotal

func GetTotal(dbName, table string, args ...string) (total int)

*

  • 查询总数
  • 2018/04/19

func Insert

func Insert(dbName, table string, data map[string]string) (int64, error)

*

  • 创建数据

func InsertByStmt

func InsertByStmt(dbName string, table string, data []string, valuelist []interface{}) (int64, error)

*

  • 使用db prepare写入数据
  • @param dbName
  • @param table 表名
  • @param data 写入的字段
  • @param valuelist 写入的值
  • GZ
  • 2020/08/06

func QueryByStmt

func QueryByStmt(sql string, valuelist []interface{}) ([]map[string]string, error)

*

  • 执行自定义查询
  • @return lastId error

func StmtForInsert

func StmtForInsert(dbName, table string, data []string) (*sql.Stmt, error)

*

  • 准备写入
  • return Stmt error

func StmtForInsertExec

func StmtForInsertExec(stmt *sql.Stmt, valuelist []interface{}) (int64, error)

*

  • 执行写入
  • @return lastId error

func StmtForQuery

func StmtForQuery(querysql string) (*sql.Stmt, error)

*

  • 自定义查询
  • return Stmt error

func StmtForQueryList

func StmtForQueryList(stmt *sql.Stmt, valuelist []interface{}) ([]map[string]string, error)

*

  • 执行查询列表
  • return list error

func StmtForQueryRow

func StmtForQueryRow(stmt *sql.Stmt, valuelist []interface{}) (map[string]string, error)

*

  • 执行查询一条数据
  • return row error

func StmtForRead

func StmtForRead(dbName, table string, title string, where []string, limit map[string]string) (*sql.Stmt, error)

*

  • 准备查询
  • return Stmt error

func StmtForUpdate

func StmtForUpdate(dbName, table string, data []string, where []string) (*sql.Stmt, error)

*

  • 准备更新
  • return Stmt error

func StmtForUpdateExec

func StmtForUpdateExec(stmt *sql.Stmt, valuelist []interface{}) (int64, error)

*

  • 执行更新
  • return is_updated error

func TxDelete

func TxDelete(tx *sql.Tx, dbname, table string, where map[string]string, del_count ...string) (int64, error)

*

  • 删除数据
  • @param count 删除数量

func TxForRead

func TxForRead(tx *sql.Tx, dbName, table string, title string, where []string) (*sql.Stmt, error)

*

  • 准备查询
  • return Stmt error

func TxGetData

func TxGetData(tx *sql.Tx, dbName string, table string, title string, where []string, valuelist []interface{}) (map[string]string, error)

*

  • 使用db prepare方式查询单条数据
  • @param dbName
  • @param title 查询的字段名
  • @param where 查询条件
  • @param valuelist 查询的条件值
  • @param limit 查询排序
  • GZ
  • 2020/05/19

func TxInsert

func TxInsert(tx *sql.Tx, dbname, table string, data map[string]string) (int64, error)

*

  • 创建数据

func TxPreInsert

func TxPreInsert(tx *sql.Tx, dbname, table string, data map[string]interface{}) (int64, error)

*

  • 准备写入
  • return Stmt error

func TxPreUpdate

func TxPreUpdate(tx *sql.Tx, dbname, table string, data []string, where []string, valuelist []interface{}) (int64, error)

*

  • 准备更新
  • return Stmt error

func TxUpdate

func TxUpdate(tx *sql.Tx, dbname, table string, data map[string]string, where map[string]string) (int64, error)

*

  • 修改数据

func Update

func Update(dbName, table string, data map[string]string, where map[string]string) (int64, error)

*

  • 修改数据

func UpdateByStmt

func UpdateByStmt(dbName string, table string, data []string, where []string, valuelist []interface{}) (int64, error)

*

  • 使用db prepare修改数据
  • @param dbName
  • @param title 查询的字段名
  • @param where 查询条件
  • @param valuelist 查询的条件值
  • @param limit 查询排序
  • GZ
  • 2020/05/19

Types

This section is empty.

Jump to

Keyboard shortcuts

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