sqlutil

package
v0.0.0-...-54a0d76 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2014 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSelectOneGetMore = errors.New("SelectOne: got multiple rows")
)
View Source
var HTML_Paging = `` /* 140-byte string literal not displayed */
View Source
var HTML_Paging_Elements = map[string]string{
	"FIRST": "[page] : href='[href]'",
	"PREVN": "[page] : href='[href]'",
	"PREV":  "[page] : href='[href]'",
	"NEXT":  "[page] : href='[href]'",
	"NEXTN": "[page] : href='[href]'",
	"LAST":  "[page] : href='[href]'",
	"INFO":  "[page]/[count]",

	"SELECT": "\t[page]# href='[href]'\n",
	"AROUND": "\thref='[href]', [page]\n",
}

Functions

This section is empty.

Types

type ColumnMap

type ColumnMap interface {
}

type DbMap

type DbMap interface {
	SQLExecutor
	Begin() (Transaction, error)
	//
	GetTableByName(t string) (TableMap, bool)
	GetTableByMeta(meta interface{}) (TableMap, bool)
	AddTable(meta interface{}, name string) (TableMap, error)
	AddTable2(meta interface{}, name, comment string) (TableMap, error)
	AddTable3(meta interface{}, schema, name, comment string) (TableMap, error)
	CreateTables(ifNotExists bool, args ...interface{}) (sql string, err error)
	TruncateTables(args ...interface{}) (sql string, err error)
	DropTables(ifExists bool, args ...interface{}) (sql string, err error)
	DropTableByName(t string, ifExists bool) error
	DropTableByMeta(meta interface{}, ifExists bool) error
}

func NewDbMap

func NewDbMap(db *sql.DB, dialect dialect.Dialect) DbMap

type SQLExecutor

type SQLExecutor interface {
	dialect.Execer
	dialect.Queryer
	//
	Insert(objects ...interface{}) (int64, error)
	Update(objects ...interface{}) (int64, error)
	Delete(objects ...interface{}) (int64, error)
	Get(objects ...interface{}) (int64, error)
	//
	SelectBool(query string, args ...interface{}) (bool, error)
	SelectNullBool(query string, args ...interface{}) (sql.NullBool, error)
	SelectInt(query string, args ...interface{}) (int64, error)
	SelectNullInt(query string, args ...interface{}) (sql.NullInt64, error)
	SelectFloat(query string, args ...interface{}) (float64, error)
	SelectNullFloat(query string, args ...interface{}) (sql.NullFloat64, error)
	SelectStr(query string, args ...interface{}) (string, error)
	SelectNullStr(query string, args ...interface{}) (sql.NullString, error)
	//
	SelectVal(holder interface{}, query string, args ...interface{}) error
	SelectOne(holder interface{}, query string, args ...interface{}) error
	SelectAll(slices interface{}, query string, args ...interface{}) (int64, error)
}

type SQLQuery

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

func NewSQLQuery

func NewSQLQuery(t TableMap, args ...string) (m *SQLQuery)

func (*SQLQuery) GetAll

func (this *SQLQuery) GetAll(slices interface{}, exec SQLExecutor, args ...interface{}) (int64, error)

func (*SQLQuery) GetOne

func (this *SQLQuery) GetOne(holder interface{}, exec SQLExecutor, args ...interface{}) (err error)

func (*SQLQuery) GetPage

func (this *SQLQuery) GetPage(slices interface{}, pageNo int, args ...interface{}) (rows int64, err error)

func (*SQLQuery) GetPageBar

func (this *SQLQuery) GetPageBar(pattern string, elements map[string]string, f func(page int) string) (h string)

func (*SQLQuery) InitPage

func (this *SQLQuery) InitPage(args ...interface{})

func (*SQLQuery) InitPage1

func (this *SQLQuery) InitPage1(where string, args ...interface{})

func (*SQLQuery) InitPage2

func (this *SQLQuery) InitPage2(fields, where string, args ...interface{})

func (*SQLQuery) MakeSQL

func (this *SQLQuery) MakeSQL(pageMode bool, suffixes ...string) (s string)

func (*SQLQuery) SetAs

func (this *SQLQuery) SetAs(args ...string) *SQLQuery

func (*SQLQuery) SetFields

func (this *SQLQuery) SetFields(s string) *SQLQuery

func (*SQLQuery) SetGroupBy

func (this *SQLQuery) SetGroupBy(s string) *SQLQuery

func (*SQLQuery) SetHaving

func (this *SQLQuery) SetHaving(s string) *SQLQuery

func (*SQLQuery) SetJoin

func (this *SQLQuery) SetJoin(s string) *SQLQuery

func (*SQLQuery) SetLimit

func (this *SQLQuery) SetLimit(s string) *SQLQuery

func (*SQLQuery) SetOrderBy

func (this *SQLQuery) SetOrderBy(s string) *SQLQuery

func (*SQLQuery) SetPageMode

func (this *SQLQuery) SetPageMode(maxNavPage, rowsPerPage int)

func (*SQLQuery) SetSuffixes

func (this *SQLQuery) SetSuffixes(suffixes ...string) *SQLQuery

func (*SQLQuery) SetWhere

func (this *SQLQuery) SetWhere(s string) *SQLQuery

type StmtBind

type StmtBind interface {
	Close() error
	Exec(args ...interface{}) (sql.Result, error)
	Query(args ...interface{}) error
	Next() error
	One() error
}

func NewStmt

func NewStmt(db *sql.DB, query string, data ...interface{}) (StmtBind, error)

func NewStmtBind

func NewStmtBind(stmt *sql.Stmt, data ...interface{}) StmtBind

type TableMap

type TableMap interface {
	SQLExecutor
	//
	CreateSQL(ifNotExists bool) string
	Create(ifNotExists bool) error
	DropSQL(ifExists bool) string
	Drop(ifExists bool) error
	TruncateSQL() string
	Truncate() error

	//
	Insert2(exec SQLExecutor, data map[string]string, except []string) (id int64, err error)
	Update2(exec SQLExecutor, where string, data map[string]string, except []string) (rows int64, err error)
	Delete2(exec SQLExecutor, where string) (rows int64, err error)
	SelectVal2(holder interface{}, where string, args ...interface{}) error
	SelectOne2(holder interface{}, where string, args ...interface{}) error
	SelectAll2(slices interface{}, where string, args ...interface{}) (int64, error)
	SelectVal2x(holder interface{}, where, suffix string, args ...interface{}) error
	SelectOne2x(holder interface{}, where, suffix string, args ...interface{}) error
	SelectAll2x(slices interface{}, where, suffix string, args ...interface{}) (int64, error)
	SelectVal3(holder interface{}, fields, where string, args ...interface{}) error
	SelectOne3(holder interface{}, fields, where string, args ...interface{}) error
	SelectAll3(slices interface{}, fields, where string, args ...interface{}) (int64, error)
	SelectVal3x(holder interface{}, fields, where, suffix string, args ...interface{}) error
	SelectOne3x(holder interface{}, fields, where, suffix string, args ...interface{}) error
	SelectAll3x(slices interface{}, fields, where, suffix string, args ...interface{}) (int64, error)
	// contains filtered or unexported methods
}

type Transaction

type Transaction interface {
	SQLExecutor
	//
	Commit() error
	Rollback() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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