orm

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2017 License: GPL-3.0 Imports: 10 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	IP       string
	Port     int
	DBName   string
	UserName string
	Passwd   string
	Charset  string
	TimeOut  string
}

DB db instance.

func NewDB

func NewDB(ip string, port int, dbName, user, pass, charset, timeout string) *DB

NewDB create db instance.

func (*DB) GetConnection

func (db *DB) GetConnection() (*sql.DB, error)

GetConnection open new connect to db.

type Stmt

type Stmt struct {
	// contains filtered or unexported fields
}

Stmt db stmt.

func NewStmt

func NewStmt(db *sql.DB, table string) *Stmt

NewStmt new db stmt.

func (*Stmt) Count

func (s *Stmt) Count() (int64, error)

Count 查询总数.

func (*Stmt) Group

func (s *Stmt) Group(group string) *Stmt

Group 添加group by.

func (*Stmt) Insert

func (s *Stmt) Insert(data interface{}) (int64, error)

Insert sql update db.

func (*Stmt) Limit

func (s *Stmt) Limit(limit int) *Stmt

Limit 添加limit

func (*Stmt) Offset

func (s *Stmt) Offset(offset int) *Stmt

Offset 添加offset

func (*Stmt) Order

func (s *Stmt) Order(order string) *Stmt

Order 添加order

func (*Stmt) Query

func (s *Stmt) Query(result interface{}) error

Query 根据传入的result结构,生成查询sql,并返回执行结果, result 必需是一个指向切片的指针.

func (*Stmt) SQLColumn

func (s *Stmt) SQLColumn(rt reflect.Type, table string) string

SQLColumn 生成查询需要的列,目前只是内部用.

func (*Stmt) SQLCondition

func (s *Stmt) SQLCondition(bs *bytes.Buffer) *bytes.Buffer

SQLCondition where, order, limit

func (*Stmt) SQLCount

func (s *Stmt) SQLCount() string

SQLCount 根据条件及结构生成查询sql

func (*Stmt) SQLInsert

func (s *Stmt) SQLInsert(rt reflect.Type, rv reflect.Value) (sql string, refs []interface{})

SQLInsert 添加数据

func (*Stmt) SQLQuery

func (s *Stmt) SQLQuery(rt reflect.Type) string

SQLQuery 根据条件及结构生成查询sql

func (*Stmt) SQLQueryBuilder

func (s *Stmt) SQLQueryBuilder(result interface{}) (string, error)

SQLQueryBuilder build sql query.

func (*Stmt) SQLUpdate

func (s *Stmt) SQLUpdate(rt reflect.Type, rv reflect.Value) (sql string, refs []interface{})

SQLUpdate 根据条件及结构生成update sql

func (*Stmt) Sort

func (s *Stmt) Sort(sort string) *Stmt

Sort 添加sort

func (*Stmt) Update

func (s *Stmt) Update(data interface{}) (int64, error)

Update sql update db.

func (*Stmt) Where

func (s *Stmt) Where(f string, args ...interface{}) *Stmt

Where 添加查询条件

Jump to

Keyboard shortcuts

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