Documentation ¶
Index ¶
- Constants
- Variables
- func AddSlave(db *sql.DB, db_name string, weight int) error
- func CopyDataFromModel(md *DbModel, vo_ptr interface{}, mo_ptr interface{}) (int, error)
- func CopyDataToModel(md *DbModel, vo_ptr interface{}, mo_ptr interface{}) (int, error)
- func CreateIntArray(arr_ptr interface{}, field string, def_val ...int64) ([]int64, error)
- func GetBool(md *DbModel, fld_ptr *bool) bool
- func GetDirectType(t reflect.Type) reflect.Type
- func GetFloat32(md *DbModel, fld_ptr *float32) float32
- func GetFloat64(md *DbModel, fld_ptr *float64) float64
- func GetIndirect(md *DbModel, fld_ptr interface{}) interface{}
- func GetInt(md *DbModel, fld_ptr *int) int
- func GetInt32(md *DbModel, fld_ptr *int32) int32
- func GetInt64(md *DbModel, fld_ptr *int64) int64
- func GetPointer(md *DbModel, fld_ptr interface{}) interface{}
- func GetString(md *DbModel, fld_ptr *string) string
- func GetTime(md *DbModel, fld_ptr *time.Time) time.Time
- func InitEngine(dialect Dialect, db *sql.DB) error
- func InitMysql(db *sql.DB) error
- func InitPostgres(db *sql.DB) error
- func InitSqlServer(db *sql.DB) error
- func InitSqlite3(db *sql.DB) error
- func LLike(val string) string
- func LRLike(val string) string
- func OpenDb() (*sql.DB, error)
- func OpenSalveDb() (*sql.DB, error)
- func RLike(val string) string
- func Scan(rows DbRows, dest ...interface{}) error
- func ScanModel(rows DbRows, ent_ptr interface{}) error
- func SetDebugLogLevel(level Level)
- func SetMaxStmtCacheNum(max_len int)
- func SetSqlLogCB(cb SqlPrintCB)
- func SetValue(md *DbModel, fld_ptr interface{}, val interface{}) error
- func ShowSqlLog(flag bool)
- func UsePrepare(flag bool)
- type AfterDeleteInterface
- type AfterInsertInterface
- type AfterQueryInterface
- type AfterUpdateInterface
- type BatchResult
- type BeforeDeleteInterface
- type BeforeInsertInterface
- type BeforeQueryInterface
- type BeforeUpdateInterface
- type ColumnInfo
- type DbEngine
- func (engine *DbEngine) AddSlave(db *sql.DB, db_name string, weight int) error
- func (engine *DbEngine) CleanStmtCache()
- func (engine *DbEngine) DB() *sql.DB
- func (engine *DbEngine) DefaultSession() *DbSession
- func (engine *DbEngine) GetDialect() Dialect
- func (engine *DbEngine) Joint(ent_ptr interface{}, alias string, fields ...string) *DbJoint
- func (engine *DbEngine) Model(ent_ptr interface{}) *DbModel
- func (engine *DbEngine) NewSession() *DbSession
- func (engine *DbEngine) SQL(sql_str string, args ...interface{}) *DbSQL
- func (engine *DbEngine) SetMaxStmtCacheNum(max_len int)
- func (engine *DbEngine) SetSqlLogCB(cb SqlPrintCB)
- func (engine *DbEngine) ShowSqlLog(flag bool)
- func (engine *DbEngine) Table(table_name string) *DbTable
- func (dbs *DbEngine) UsePrepare(flag bool)
- type DbJoint
- func (lk *DbJoint) And(sql string, vals ...interface{}) *DbJoint
- func (lk *DbJoint) AndExp(sqlw_sub *DbWhere) *DbJoint
- func (lk *DbJoint) AndIf(cond bool, sql string, vals ...interface{}) *DbJoint
- func (lk *DbJoint) AndIn(sql string, vals ...interface{}) *DbJoint
- func (lk *DbJoint) AndNotIn(sql string, vals ...interface{}) *DbJoint
- func (lk *DbJoint) Context(ctx context.Context) *DbJoint
- func (lk *DbJoint) CopyModelData2Eo(cache *JointEoFieldCache, v_vo reflect.Value)
- func (lk *DbJoint) CopyModelData2Vo(vo_ptr VoLoader)
- func (lk *DbJoint) Find(arr_ptr interface{}) error
- func (lk *DbJoint) Get(args ...interface{}) (bool, error)
- func (lk *DbJoint) GetContext() context.Context
- func (lk *DbJoint) Join(ent_ptr interface{}, alias string, join_on string, fields ...string) *DbJoint
- func (lk *DbJoint) LeftJoin(ent_ptr interface{}, alias string, join_on string, fields ...string) *DbJoint
- func (lk *DbJoint) Limit(rows int64) *DbJoint
- func (lk *DbJoint) Offset(offset int64) *DbJoint
- func (lk *DbJoint) Or(sql string, vals ...interface{}) *DbJoint
- func (lk *DbJoint) OrExp(sqlw_sub *DbWhere) *DbJoint
- func (lk *DbJoint) OrIf(cond bool, sql string, vals ...interface{}) *DbJoint
- func (lk *DbJoint) OrIn(sql string, vals ...interface{}) *DbJoint
- func (lk *DbJoint) OrNotIn(sql string, vals ...interface{}) *DbJoint
- func (lk *DbJoint) OrderBy(val string) *DbJoint
- func (lk *DbJoint) Page(rows int64, page_no int64) *DbJoint
- func (lk *DbJoint) RightJoin(ent_ptr interface{}, alias string, join_on string, fields ...string) *DbJoint
- func (lk *DbJoint) Scan() (bool, error)
- func (lk *DbJoint) SetWhere(sqlw *DbWhere) *DbJoint
- func (lk *DbJoint) ShowLog(val bool) *DbJoint
- func (lk *DbJoint) Top(rows int64) *DbJoint
- func (lk *DbJoint) UseMaster(val bool) *DbJoint
- func (lk *DbJoint) UsePrepare(val bool) *DbJoint
- func (lk *DbJoint) Where(sql string, vals ...interface{}) *DbJoint
- func (lk *DbJoint) WhereIf(cond bool, sql string, vals ...interface{}) *DbJoint
- func (lk *DbJoint) WhereIn(sql string, vals ...interface{}) *DbJoint
- func (lk *DbJoint) WhereNotIn(sql string, vals ...interface{}) *DbJoint
- type DbModel
- func (md *DbModel) AddField(fields ...string) *DbModel
- func (md *DbModel) AddFieldX(fields ...interface{}) *DbModel
- func (md *DbModel) And(sql string, vals ...interface{}) *DbModel
- func (md *DbModel) AndExp(sqlw_sub *DbWhere) *DbModel
- func (md *DbModel) AndIf(cond bool, sql string, vals ...interface{}) *DbModel
- func (md *DbModel) AndIn(sql string, vals ...interface{}) *DbModel
- func (md *DbModel) AndNotIn(sql string, vals ...interface{}) *DbModel
- func (md *DbModel) AndX(field_ptr interface{}, oper string, vals ...interface{}) *DbModel
- func (md *DbModel) BatchInsert(arr_ptr interface{}) (sql.Result, error)
- func (md *DbModel) Context(ctx context.Context) *DbModel
- func (md *DbModel) Count(field ...string) (int64, error)
- func (md *DbModel) Delete() (int64, error)
- func (md *DbModel) DistinctCount(field string) (int64, error)
- func (md *DbModel) Exist() (bool, error)
- func (md *DbModel) Find(arr_ptr interface{}) error
- func (md *DbModel) Get(args ...interface{}) (bool, error)
- func (md *DbModel) GetContext() context.Context
- func (md *DbModel) GetFieldFlag4Insert(i int) bool
- func (md *DbModel) GetFieldFlag4Select(i int) bool
- func (md *DbModel) GetFieldFlag4Update(i int) bool
- func (md *DbModel) GetIf(flag bool, args ...interface{}) (bool, error)
- func (md *DbModel) GetModelEnt() interface{}
- func (md *DbModel) ID(val int64) *DbModel
- func (md *DbModel) Insert(args ...interface{}) (int64, error)
- func (md *DbModel) InsertIfNotExist(args ...interface{}) (affected int64, insertId int64, err error)
- func (md *DbModel) Limit(rows int64) *DbModel
- func (md *DbModel) Lock(val string) *DbModel
- func (md *DbModel) Offset(offset int64) *DbModel
- func (md *DbModel) Omit(fields ...string) *DbModel
- func (md *DbModel) OmitALL() *DbModel
- func (md *DbModel) OmitX(fields ...interface{}) *DbModel
- func (md *DbModel) Or(sql string, vals ...interface{}) *DbModel
- func (md *DbModel) OrExp(sqlw_sub *DbWhere) *DbModel
- func (md *DbModel) OrIf(cond bool, sql string, vals ...interface{}) *DbModel
- func (md *DbModel) OrIn(sql string, vals ...interface{}) *DbModel
- func (md *DbModel) OrNotIn(sql string, vals ...interface{}) *DbModel
- func (md *DbModel) OrX(field_ptr interface{}, oper string, vals ...interface{}) *DbModel
- func (md *DbModel) OrderBy(val string) *DbModel
- func (md *DbModel) Page(rows int64, page_no int64) *DbModel
- func (md *DbModel) Reset()
- func (md *DbModel) Rows() (ModelRows, error)
- func (md *DbModel) Save(args ...interface{}) (affected int64, insertId int64, err error)
- func (md *DbModel) Scan() (bool, error)
- func (md *DbModel) Select(fields ...string) *DbModel
- func (md *DbModel) SelectALL() *DbModel
- func (md *DbModel) SelectX(fields ...interface{}) *DbModel
- func (md *DbModel) SetDbSession(dbs *DbSession) *DbModel
- func (md *DbModel) SetValue(fld_ptr interface{}, val interface{}) error
- func (md *DbModel) SetWhere(sqlw *DbWhere) *DbModel
- func (md *DbModel) ShowLog(val bool) *DbModel
- func (md *DbModel) Table(val string) *DbModel
- func (md *DbModel) TableAlias(alias string) *DbJoint
- func (md *DbModel) TableName(val string) *DbModel
- func (md *DbModel) Top(rows int64) *DbModel
- func (md *DbModel) Update(args ...interface{}) (int64, error)
- func (md *DbModel) UpdateOrInsert(id int64, args ...interface{}) (affected int64, entId int64, err error)
- func (md *DbModel) UseMaster(val bool) *DbModel
- func (md *DbModel) UsePrepare(val bool) *DbModel
- func (md *DbModel) Where(sql string, vals ...interface{}) *DbModel
- func (md *DbModel) WhereIf(cond bool, sql string, vals ...interface{}) *DbModel
- func (md *DbModel) WhereIn(sql string, vals ...interface{}) *DbModel
- func (md *DbModel) WhereNotIn(sql string, vals ...interface{}) *DbModel
- type DbRows
- type DbSQL
- func (tb *DbSQL) Context(ctx context.Context) *DbSQL
- func (tb *DbSQL) Exec() (sql.Result, error)
- func (tb *DbSQL) FindFloat() ([]float64, error)
- func (tb *DbSQL) FindInt() ([]int64, error)
- func (tb *DbSQL) FindIntFloat() ([]KeyVal4IntFloat, error)
- func (tb *DbSQL) FindIntInt() ([]KeyVal4IntInt, error)
- func (tb *DbSQL) FindIntString() ([]KeyVal4IntString, error)
- func (tb *DbSQL) FindIntTime() ([]KeyVal4IntTime, error)
- func (tb *DbSQL) FindModel(arr_ptr interface{}) error
- func (tb *DbSQL) FindRow() (*StringTable, error)
- func (tb *DbSQL) FindString() ([]string, error)
- func (tb *DbSQL) FindStringFloat() ([]KeyVal4StringFloat, error)
- func (tb *DbSQL) FindStringInt() ([]KeyVal4StringInt, error)
- func (tb *DbSQL) FindStringString() ([]KeyVal4StringString, error)
- func (tb *DbSQL) FindStringTime() ([]KeyVal4StringTime, error)
- func (tb *DbSQL) FindTime() ([]time.Time, error)
- func (tb *DbSQL) FindValues(arr_ptr_arr ...interface{}) (int, error)
- func (tb *DbSQL) Get(arg ...interface{}) (bool, error)
- func (tb *DbSQL) GetContext() context.Context
- func (tb *DbSQL) GetFloat() (sql.NullFloat64, error)
- func (tb *DbSQL) GetInt() (sql.NullInt64, error)
- func (tb *DbSQL) GetModel(ent_ptr interface{}) (bool, error)
- func (tb *DbSQL) GetRow() (StringRow, error)
- func (tb *DbSQL) GetString() (sql.NullString, error)
- func (tb *DbSQL) GetTime() (sql.NullTime, error)
- func (tb *DbSQL) GetValues(arg ...interface{}) (bool, error)
- func (tb *DbSQL) ModelRows() (StructRows, error)
- func (tb *DbSQL) Rows() (DbRows, error)
- func (tb *DbSQL) ShowLog(val bool) *DbSQL
- func (tb *DbSQL) SqlRows() (*sql.Rows, error)
- func (tb *DbSQL) StringRows() (StringRows, error)
- func (tb *DbSQL) UseMaster(val bool) *DbSQL
- func (tb *DbSQL) UsePrepare(val bool) *DbSQL
- type DbSession
- func (dbs *DbSession) DB() *sql.DB
- func (dbs *DbSession) ExecQuery(ctx *SqlContex, sql_tpl string, args ...interface{}) (res *sql.Rows, err error)
- func (dbs *DbSession) ExecSQL(ctx *SqlContex, sql_tpl string, args ...interface{}) (res sql.Result, err error)
- func (dbs *DbSession) Joint(ent_ptr interface{}, alias string, fields ...string) *DbJoint
- func (dbs *DbSession) Model(ent_ptr interface{}) *DbModel
- func (dbs *DbSession) NewModel(ent_ptr interface{}, flag bool) *DbModel
- func (dbs *DbSession) Prepare(sql_tpl string) (*sql.Stmt, error)
- func (dbs *DbSession) SQL(sql_str string, args ...interface{}) *DbSQL
- func (dbs *DbSession) ShowLog(flag bool)
- func (dbs *DbSession) Table(table_name string) *DbTable
- func (dbs *DbSession) Tx() *sql.Tx
- func (dbs *DbSession) TxBegin() error
- func (dbs *DbSession) TxCommit() error
- func (dbs *DbSession) TxRollback() error
- func (dbs *DbSession) UsePrepare(flag bool)
- type DbSlave
- type DbTable
- func (tb *DbTable) Alias(alias string) *DbTable
- func (tb *DbTable) And(sql string, vals ...interface{}) *DbTable
- func (tb *DbTable) AndExp(sqlw_sub *DbWhere) *DbTable
- func (tb *DbTable) AndIf(cond bool, sql string, vals ...interface{}) *DbTable
- func (tb *DbTable) AndIn(sql string, vals ...interface{}) *DbTable
- func (tb *DbTable) AndNotIn(sql string, vals ...interface{}) *DbTable
- func (tb *DbTable) Context(ctx context.Context) *DbTable
- func (tb *DbTable) Count(field ...string) (int64, error)
- func (tb *DbTable) Delete() (int64, error)
- func (tb *DbTable) DistinctCount(field string) (int64, error)
- func (tb *DbTable) Exist() (bool, error)
- func (tb *DbTable) FindFloat() ([]float64, error)
- func (tb *DbTable) FindInt() ([]int64, error)
- func (tb *DbTable) FindIntFloat() ([]KeyVal4IntFloat, error)
- func (tb *DbTable) FindIntInt() ([]KeyVal4IntInt, error)
- func (tb *DbTable) FindIntString() ([]KeyVal4IntString, error)
- func (tb *DbTable) FindIntTime() ([]KeyVal4IntTime, error)
- func (tb *DbTable) FindModel(arr_ptr interface{}) error
- func (tb *DbTable) FindRow() (*StringTable, error)
- func (tb *DbTable) FindString() ([]string, error)
- func (tb *DbTable) FindStringFloat() ([]KeyVal4StringFloat, error)
- func (tb *DbTable) FindStringInt() ([]KeyVal4StringInt, error)
- func (tb *DbTable) FindStringString() ([]KeyVal4StringString, error)
- func (tb *DbTable) FindStringTime() ([]KeyVal4StringTime, error)
- func (tb *DbTable) FindTime() ([]time.Time, error)
- func (tb *DbTable) FindValues(arr_ptr_arr ...interface{}) (int, error)
- func (tb *DbTable) Get(arg ...interface{}) (bool, error)
- func (tb *DbTable) GetContext() context.Context
- func (tb *DbTable) GetFlaot() (sql.NullFloat64, error)
- func (tb *DbTable) GetFloat() (sql.NullFloat64, error)
- func (tb *DbTable) GetInt() (sql.NullInt64, error)
- func (tb *DbTable) GetModel(ent_ptr interface{}) (bool, error)
- func (tb *DbTable) GetRow() (StringRow, error)
- func (tb *DbTable) GetString() (sql.NullString, error)
- func (tb *DbTable) GetTime() (sql.NullTime, error)
- func (tb *DbTable) GetValues(arg ...interface{}) (bool, error)
- func (tb *DbTable) GroupBy(val string) *DbTable
- func (tb *DbTable) Having(sql string, vals ...interface{}) *DbTable
- func (tb *DbTable) ID(val int64) *DbTable
- func (tb *DbTable) Insert() (int64, error)
- func (tb *DbTable) Join(table string, alias string, join_on string) *DbTable
- func (tb *DbTable) LeftJoin(table string, alias string, join_on string) *DbTable
- func (tb *DbTable) Limit(rows int64) *DbTable
- func (tb *DbTable) Lock(val string) *DbTable
- func (tb *DbTable) ModelRows() (StructRows, error)
- func (tb *DbTable) Offset(offset int64) *DbTable
- func (tb *DbTable) Or(sql string, vals ...interface{}) *DbTable
- func (tb *DbTable) OrExp(sqlw_sub *DbWhere) *DbTable
- func (tb *DbTable) OrIf(cond bool, sql string, vals ...interface{}) *DbTable
- func (tb *DbTable) OrIn(sql string, vals ...interface{}) *DbTable
- func (tb *DbTable) OrNotIn(sql string, vals ...interface{}) *DbTable
- func (tb *DbTable) OrderBy(val string) *DbTable
- func (tb *DbTable) Output(output string) *DbTable
- func (tb *DbTable) Page(rows int64, page_no int64) *DbTable
- func (tb *DbTable) ReturnIng(returning string) *DbTable
- func (tb *DbTable) RightJoin(table string, alias string, join_on string) *DbTable
- func (tb *DbTable) Rows() (DbRows, error)
- func (tb *DbTable) Select(fields ...string) *DbTable
- func (tb *DbTable) SetWhere(sqlw *DbWhere) *DbTable
- func (tb *DbTable) ShowLog(val bool) *DbTable
- func (tb *DbTable) SqlRows() (*sql.Rows, error)
- func (tb *DbTable) StringRows() (StringRows, error)
- func (tb *DbTable) Top(rows int64) *DbTable
- func (tb *DbTable) Update() (int64, error)
- func (tb *DbTable) UseMaster(val bool) *DbTable
- func (tb *DbTable) UsePrepare(val bool) *DbTable
- func (tb *DbTable) Value(col_name string, val interface{}) *DbTable
- func (tb *DbTable) Values(map_data ValueMap) *DbTable
- func (tb *DbTable) Where(sql string, vals ...interface{}) *DbTable
- func (tb *DbTable) WhereIf(cond bool, sql string, vals ...interface{}) *DbTable
- func (tb *DbTable) WhereIn(sql string, vals ...interface{}) *DbTable
- func (tb *DbTable) WhereNotIn(sql string, vals ...interface{}) *DbTable
- type DbWhere
- func (sqlw *DbWhere) And(sql string, vals ...interface{}) *DbWhere
- func (sqlw *DbWhere) AndExp(sqlw_sub *DbWhere) *DbWhere
- func (sqlw *DbWhere) AndIf(cond bool, sql string, vals ...interface{}) *DbWhere
- func (sqlw *DbWhere) AndIn(field string, vals ...interface{}) *DbWhere
- func (sqlw *DbWhere) AndNotIn(field string, vals ...interface{}) *DbWhere
- func (sqlw *DbWhere) GenPlatSQl() string
- func (sqlw *DbWhere) GetTpl() string
- func (sqlw *DbWhere) GetValues() []interface{}
- func (sqlw *DbWhere) Init(sql string, vals ...interface{}) *DbWhere
- func (sqlw *DbWhere) Or(sql string, vals ...interface{}) *DbWhere
- func (sqlw *DbWhere) OrExp(sqlw_sub *DbWhere) *DbWhere
- func (sqlw *DbWhere) OrIf(cond bool, sql string, vals ...interface{}) *DbWhere
- func (sqlw *DbWhere) OrIn(field string, vals ...interface{}) *DbWhere
- func (sqlw *DbWhere) OrNotIn(field string, vals ...interface{}) *DbWhere
- func (sqlw *DbWhere) Reset()
- type Dialect
- type DialectBase
- func (db *DialectBase) DbType2GoType(colType string) string
- func (db *DialectBase) GenJointFindSql(lk *DbJoint) string
- func (db *DialectBase) GenJointGetSql(lk *DbJoint) string
- func (db *DialectBase) GenModelDeleteSql(md *DbModel) string
- func (db *DialectBase) GenModelFindSql(md *DbModel) string
- func (db *DialectBase) GenModelGetSql(md *DbModel) string
- func (db *DialectBase) GenModelInsertSql(md *DbModel) string
- func (db *DialectBase) GenModelUpdateSql(md *DbModel) string
- func (db *DialectBase) GenTableDeleteSql(tb *DbTable) string
- func (db *DialectBase) GenTableFindSql(tb *DbTable) string
- func (db *DialectBase) GenTableGetSql(tb *DbTable) string
- func (db *DialectBase) GenTableInsertSql(tb *DbTable) (string, []interface{})
- func (db *DialectBase) GenTableUpdateSql(tb *DbTable) (string, []interface{})
- func (db *DialectBase) GetColumns(db_raw *sql.DB, tableName string) ([]ColumnInfo, error)
- func (db *DialectBase) GetName() string
- func (db *DialectBase) LimitSql(offset int64, limit int64) string
- func (db *DialectBase) ModelInsertHasOutput(md *DbModel) bool
- func (db *DialectBase) ParsePlaceholder(sql_tpl string) string
- func (db *DialectBase) TableInsertHasOutput(tb *DbTable) bool
- type FieldIndex
- type FieldInfo
- type FieldPos
- type FieldValue
- type JointEoFieldCache
- type KeyVal
- type KeyVal4IntFloat
- type KeyVal4IntInt
- type KeyVal4IntString
- type KeyVal4IntTime
- type KeyVal4StringFloat
- type KeyVal4StringInt
- type KeyVal4StringString
- type KeyVal4StringTime
- type Level
- type LogContex
- type LogPrintCB
- type ModelInfo
- type ModelPool
- type ModelRows
- type PublicFields
- type ScanArray
- type SimpleLogger
- func (lg *SimpleLogger) Debug(v ...interface{})
- func (lg *SimpleLogger) Debugf(format string, v ...interface{})
- func (lg *SimpleLogger) Error(v ...interface{})
- func (lg *SimpleLogger) Errorf(format string, v ...interface{})
- func (lg *SimpleLogger) Fatal(v ...interface{})
- func (lg *SimpleLogger) Fatalf(format string, v ...interface{})
- func (lg *SimpleLogger) Info(v ...interface{})
- func (lg *SimpleLogger) Infof(format string, v ...interface{})
- func (lg *SimpleLogger) Output(level_str string, msg string) error
- func (lg *SimpleLogger) SetLevel(level Level)
- func (lg *SimpleLogger) Warn(v ...interface{})
- func (lg *SimpleLogger) Warnf(format string, v ...interface{})
- type SqlContex
- type SqlExp
- type SqlPrintCB
- type StmtCache
- func (sc *StmtCache) CleanStmtList()
- func (sc *StmtCache) CleanWasteList(tm_now int64)
- func (sc *StmtCache) Close()
- func (sc *StmtCache) GetStmt(query string) (*sql.Stmt, bool)
- func (sc *StmtCache) Prepare(dbs *DbSession, db *sql.DB, query string) (*sql.Stmt, int, error)
- func (sc *StmtCache) RemoveOldest()
- func (sc *StmtCache) SetStmt(query string, stmt *sql.Stmt)
- func (sc *StmtCache) TryCleanWasteList()
- type StmtItem
- type StringPair
- type StringRow
- type StringRows
- type StringTable
- type StructRows
- type TableName
- type ValueArray
- type ValueMap
- type VoLoader
- type VoSaver
Constants ¶
const ( JOIN_INNER int = 0 JOIN_LJOIN int = 1 JOIN_RJOIN int = 2 )
const ( SQL_TYPE_INS int = 1 SQL_TYPE_UPD int = 2 SQL_TYPE_DEL int = 3 SQL_TYPE_SEL int = 4 )
const ( STR_AUTOINCR string = "autoincr" //自增int STR_AUTOID string = "autoid" //自增型单主键 STR_INTID string = "intid" //int型单主键 STR_NOT_INSERT string = "n_insert" //构造insert语句时忽略 STR_NOT_UPDATE string = "n_update" //构造update语句时忽略 STR_NOT_SELECT string = "n_select" //构造select语句时忽略 )
const ( STMT_NOT_USE int = 0 STMT_EXE_PREPARE int = 1 STMT_USE_CACHE int = 2 )
返回参数中的状态:1 没有命中cache, 2 命中cache
const MaxNestDeep int = 10
匿名字段嵌套的最大深度
Variables ¶
var DbConn *sql.DB = nil
var SlaveDb *sql.DB = nil
Functions ¶
func CopyDataFromModel ¶
执行vo=mo的赋值操作,只有名称相同、类型相同的字段才能赋值 若md != nil,则获取mo的字段地址,并调用md的set_flag_by_addr函数来选中该字段
func CopyDataToModel ¶
执行mo=vo的赋值操作,只有名称相同、类型相同的字段才能赋值 若md != nil,则获取mo的字段地址,并调用md的set_flag_by_addr函数来选中该字段
func CreateIntArray ¶
从对象数组中获取整形字段的值
func GetFloat32 ¶
func GetFloat64 ¶
func GetIndirect ¶
func GetIndirect(md *DbModel, fld_ptr interface{}) interface{}
func GetPointer ¶
func GetPointer(md *DbModel, fld_ptr interface{}) interface{}
func InitPostgres ¶
func InitSqlServer ¶
func InitSqlite3 ¶
func OpenSalveDb ¶ added in v1.0.6
func SetDebugLogLevel ¶
func SetDebugLogLevel(level Level)
func SetMaxStmtCacheNum ¶
func SetMaxStmtCacheNum(max_len int)
func SetSqlLogCB ¶
func SetSqlLogCB(cb SqlPrintCB)
func ShowSqlLog ¶
func ShowSqlLog(flag bool)
func UsePrepare ¶
func UsePrepare(flag bool)
Types ¶
type AfterDeleteInterface ¶
type AfterInsertInterface ¶
type AfterQueryInterface ¶
type AfterUpdateInterface ¶
type BatchResult ¶
func (*BatchResult) LastInsertId ¶
func (this *BatchResult) LastInsertId() (int64, error)
func (*BatchResult) RowsAffected ¶
func (this *BatchResult) RowsAffected() (int64, error)
type BeforeDeleteInterface ¶
type BeforeInsertInterface ¶
type BeforeQueryInterface ¶
type BeforeUpdateInterface ¶
type ColumnInfo ¶
type DbEngine ¶
type DbEngine struct {
// contains filtered or unexported fields
}
func GetDefaultDbEngine ¶ added in v1.1.2
func GetDefaultDbEngine() *DbEngine
func (*DbEngine) DefaultSession ¶ added in v1.1.2
func (*DbEngine) NewSession ¶
func (*DbEngine) SetMaxStmtCacheNum ¶
设置可缓存的最大stmt数量
type DbJoint ¶
func (*DbJoint) CopyModelData2Eo ¶ added in v1.1.0
func (lk *DbJoint) CopyModelData2Eo(cache *JointEoFieldCache, v_vo reflect.Value)
把Model中地址的值赋值给vo对象
func (*DbJoint) CopyModelData2Vo ¶ added in v1.1.0
把Model中地址的值赋值给vo对象
func (*DbJoint) GetContext ¶
func (*DbJoint) UsePrepare ¶
func (*DbJoint) WhereNotIn ¶
type DbModel ¶
func (*DbModel) BatchInsert ¶
func (*DbModel) GetContext ¶
func (*DbModel) GetFieldFlag4Insert ¶ added in v0.2.0
func (*DbModel) GetFieldFlag4Select ¶ added in v0.2.0
func (*DbModel) GetFieldFlag4Update ¶ added in v0.2.0
func (*DbModel) GetModelEnt ¶
func (md *DbModel) GetModelEnt() interface{}
func (*DbModel) InsertIfNotExist ¶
func (md *DbModel) InsertIfNotExist(args ...interface{}) (affected int64, insertId int64, err error)
若不存在记录,则调用Insert
func (*DbModel) Reset ¶
func (md *DbModel) Reset()
重置model状态,保留以下字段的内容: ent_ptr、flds_info、flds_addr、table_name、field_id、name_map_db、name_map_go
func (*DbModel) SetDbSession ¶
func (*DbModel) TableAlias ¶
func (*DbModel) UpdateOrInsert ¶
func (md *DbModel) UpdateOrInsert(id int64, args ...interface{}) (affected int64, entId int64, err error)
id>0调用Update, 否则调用Insert
func (*DbModel) UsePrepare ¶
func (*DbModel) WhereNotIn ¶
type DbSQL ¶
type DbSQL struct { SqlContex // contains filtered or unexported fields }
func (*DbSQL) FindIntFloat ¶ added in v1.0.7
func (tb *DbSQL) FindIntFloat() ([]KeyVal4IntFloat, error)
func (*DbSQL) FindIntInt ¶ added in v1.0.7
func (tb *DbSQL) FindIntInt() ([]KeyVal4IntInt, error)
func (*DbSQL) FindIntString ¶ added in v1.0.7
func (tb *DbSQL) FindIntString() ([]KeyVal4IntString, error)
func (*DbSQL) FindIntTime ¶ added in v1.0.7
func (tb *DbSQL) FindIntTime() ([]KeyVal4IntTime, error)
func (*DbSQL) FindRow ¶
func (tb *DbSQL) FindRow() (*StringTable, error)
func (*DbSQL) FindString ¶
func (*DbSQL) FindStringFloat ¶ added in v1.0.7
func (tb *DbSQL) FindStringFloat() ([]KeyVal4StringFloat, error)
func (*DbSQL) FindStringInt ¶ added in v1.0.7
func (tb *DbSQL) FindStringInt() ([]KeyVal4StringInt, error)
func (*DbSQL) FindStringString ¶ added in v1.0.7
func (tb *DbSQL) FindStringString() ([]KeyVal4StringString, error)
func (*DbSQL) FindStringTime ¶ added in v1.0.7
func (tb *DbSQL) FindStringTime() ([]KeyVal4StringTime, error)
func (*DbSQL) FindValues ¶ added in v1.0.7
func (*DbSQL) GetContext ¶
func (*DbSQL) ModelRows ¶ added in v1.1.0
func (tb *DbSQL) ModelRows() (StructRows, error)
func (*DbSQL) StringRows ¶ added in v1.1.0
func (tb *DbSQL) StringRows() (StringRows, error)
func (*DbSQL) UsePrepare ¶
type DbSession ¶
type DbSession struct {
// contains filtered or unexported fields
}
func NewDbSession ¶
func NewSession ¶
func NewSession() *DbSession
func (*DbSession) ExecQuery ¶
func (dbs *DbSession) ExecQuery(ctx *SqlContex, sql_tpl string, args ...interface{}) (res *sql.Rows, err error)
执行数据库查询
func (*DbSession) ExecSQL ¶
func (dbs *DbSession) ExecSQL(ctx *SqlContex, sql_tpl string, args ...interface{}) (res sql.Result, err error)
执行一个sql命令
type DbTable ¶
type DbTable struct { SqlContex // contains filtered or unexported fields }
func NewDbTable ¶
func (*DbTable) FindIntFloat ¶ added in v1.0.7
func (tb *DbTable) FindIntFloat() ([]KeyVal4IntFloat, error)
func (*DbTable) FindIntInt ¶ added in v1.0.7
func (tb *DbTable) FindIntInt() ([]KeyVal4IntInt, error)
func (*DbTable) FindIntString ¶ added in v1.0.7
func (tb *DbTable) FindIntString() ([]KeyVal4IntString, error)
func (*DbTable) FindIntTime ¶ added in v1.0.7
func (tb *DbTable) FindIntTime() ([]KeyVal4IntTime, error)
func (*DbTable) FindRow ¶
func (tb *DbTable) FindRow() (*StringTable, error)
func (*DbTable) FindString ¶
func (*DbTable) FindStringFloat ¶ added in v1.0.7
func (tb *DbTable) FindStringFloat() ([]KeyVal4StringFloat, error)
func (*DbTable) FindStringInt ¶ added in v1.0.7
func (tb *DbTable) FindStringInt() ([]KeyVal4StringInt, error)
func (*DbTable) FindStringString ¶ added in v1.0.7
func (tb *DbTable) FindStringString() ([]KeyVal4StringString, error)
func (*DbTable) FindStringTime ¶ added in v1.0.7
func (tb *DbTable) FindStringTime() ([]KeyVal4StringTime, error)
func (*DbTable) FindValues ¶ added in v1.0.7
func (*DbTable) GetContext ¶
func (*DbTable) ModelRows ¶ added in v1.1.0
func (tb *DbTable) ModelRows() (StructRows, error)
func (*DbTable) StringRows ¶ added in v1.1.0
func (tb *DbTable) StringRows() (StringRows, error)
func (*DbTable) UsePrepare ¶
func (*DbTable) WhereNotIn ¶
type DbWhere ¶
type DbWhere struct { Tpl_sql string Values []interface{} }
https://gitee.com/fifsky/gosql
func (*DbWhere) GenPlatSQl ¶
type Dialect ¶
type Dialect interface { GetName() string DbType2GoType(colType string) string GetColumns(db_raw *sql.DB, tableName string) ([]ColumnInfo, error) LimitSql(offset int64, limit int64) string ParsePlaceholder(sql_tpl string) string ModelInsertHasOutput(md *DbModel) bool GenModelInsertSql(md *DbModel) string GenModelUpdateSql(md *DbModel) string GenModelDeleteSql(md *DbModel) string GenModelGetSql(md *DbModel) string GenModelFindSql(md *DbModel) string TableInsertHasOutput(tb *DbTable) bool GenTableInsertSql(tb *DbTable) (string, []interface{}) GenTableUpdateSql(tb *DbTable) (string, []interface{}) GenTableDeleteSql(tb *DbTable) string GenTableGetSql(tb *DbTable) string GenTableFindSql(tb *DbTable) string GenJointGetSql(lk *DbJoint) string GenJointFindSql(lk *DbJoint) string }
type DialectBase ¶ added in v0.3.0
type DialectBase struct { }
func (*DialectBase) DbType2GoType ¶ added in v0.3.0
func (db *DialectBase) DbType2GoType(colType string) string
func (*DialectBase) GenJointFindSql ¶ added in v0.3.0
func (db *DialectBase) GenJointFindSql(lk *DbJoint) string
func (*DialectBase) GenJointGetSql ¶ added in v0.3.0
func (db *DialectBase) GenJointGetSql(lk *DbJoint) string
func (*DialectBase) GenModelDeleteSql ¶ added in v0.3.0
func (db *DialectBase) GenModelDeleteSql(md *DbModel) string
func (*DialectBase) GenModelFindSql ¶ added in v0.3.0
func (db *DialectBase) GenModelFindSql(md *DbModel) string
func (*DialectBase) GenModelGetSql ¶ added in v0.3.0
func (db *DialectBase) GenModelGetSql(md *DbModel) string
func (*DialectBase) GenModelInsertSql ¶ added in v0.3.0
func (db *DialectBase) GenModelInsertSql(md *DbModel) string
func (*DialectBase) GenModelUpdateSql ¶ added in v0.3.0
func (db *DialectBase) GenModelUpdateSql(md *DbModel) string
func (*DialectBase) GenTableDeleteSql ¶ added in v0.3.0
func (db *DialectBase) GenTableDeleteSql(tb *DbTable) string
func (*DialectBase) GenTableFindSql ¶ added in v0.3.0
func (db *DialectBase) GenTableFindSql(tb *DbTable) string
func (*DialectBase) GenTableGetSql ¶ added in v0.3.0
func (db *DialectBase) GenTableGetSql(tb *DbTable) string
func (*DialectBase) GenTableInsertSql ¶ added in v0.3.0
func (db *DialectBase) GenTableInsertSql(tb *DbTable) (string, []interface{})
生成insert sql语句 sql语句与values数组必须在一个循环中生成,因为map多次遍历时次序可能不同
func (*DialectBase) GenTableUpdateSql ¶ added in v0.3.0
func (db *DialectBase) GenTableUpdateSql(tb *DbTable) (string, []interface{})
生成 update sql语句 sql语句与values数组必须在一个循环中生成,因为map多次遍历时次序可能不同
func (*DialectBase) GetColumns ¶ added in v0.3.0
func (db *DialectBase) GetColumns(db_raw *sql.DB, tableName string) ([]ColumnInfo, error)
func (*DialectBase) GetName ¶ added in v0.3.0
func (db *DialectBase) GetName() string
func (*DialectBase) LimitSql ¶ added in v0.3.0
func (db *DialectBase) LimitSql(offset int64, limit int64) string
func (*DialectBase) ModelInsertHasOutput ¶ added in v0.3.0
func (db *DialectBase) ModelInsertHasOutput(md *DbModel) bool
func (*DialectBase) ParsePlaceholder ¶ added in v0.3.0
func (db *DialectBase) ParsePlaceholder(sql_tpl string) string
func (*DialectBase) TableInsertHasOutput ¶ added in v0.3.0
func (db *DialectBase) TableInsertHasOutput(tb *DbTable) bool
type FieldIndex ¶ added in v1.1.0
type FieldPos ¶ added in v1.1.0
type FieldPos [MaxNestDeep]int
type FieldValue ¶
func (*FieldValue) Scan ¶
func (fd *FieldValue) Scan(value interface{}) error
Scan implements the Scanner interface.
type JointEoFieldCache ¶ added in v1.1.0
type JointEoFieldCache struct {
// contains filtered or unexported fields
}
type KeyVal4IntFloat ¶ added in v1.0.7
type KeyVal4IntInt ¶ added in v1.0.7
KeyVal use int64 as key
type KeyVal4IntString ¶ added in v1.0.7
type KeyVal4IntTime ¶ added in v1.0.7
type KeyVal4StringFloat ¶ added in v1.0.7
type KeyVal4StringInt ¶ added in v1.0.7
KeyVal use string as key
type KeyVal4StringString ¶ added in v1.0.7
type KeyVal4StringTime ¶ added in v1.0.7
type LogContex ¶
type ModelPool ¶
type ModelPool struct {
// contains filtered or unexported fields
}
func NewModelPool ¶ added in v1.1.0
type PublicFields ¶ added in v1.1.0
type PublicFields struct { //Model字段索引号 ModelField int //其他字段索引信息 Fields []FieldIndex }
func NewPublicFields ¶ added in v1.1.0
func NewPublicFields(num int) *PublicFields
type SimpleLogger ¶
type SimpleLogger struct {
// contains filtered or unexported fields
}
func NewSimpleLogger ¶
func NewSimpleLogger() *SimpleLogger
func (*SimpleLogger) Debug ¶
func (lg *SimpleLogger) Debug(v ...interface{})
func (*SimpleLogger) Debugf ¶
func (lg *SimpleLogger) Debugf(format string, v ...interface{})
func (*SimpleLogger) Error ¶
func (lg *SimpleLogger) Error(v ...interface{})
func (*SimpleLogger) Errorf ¶
func (lg *SimpleLogger) Errorf(format string, v ...interface{})
func (*SimpleLogger) Fatal ¶
func (lg *SimpleLogger) Fatal(v ...interface{})
func (*SimpleLogger) Fatalf ¶
func (lg *SimpleLogger) Fatalf(format string, v ...interface{})
func (*SimpleLogger) Info ¶
func (lg *SimpleLogger) Info(v ...interface{})
func (*SimpleLogger) Infof ¶
func (lg *SimpleLogger) Infof(format string, v ...interface{})
func (*SimpleLogger) SetLevel ¶
func (lg *SimpleLogger) SetLevel(level Level)
func (*SimpleLogger) Warn ¶
func (lg *SimpleLogger) Warn(v ...interface{})
func (*SimpleLogger) Warnf ¶
func (lg *SimpleLogger) Warnf(format string, v ...interface{})
type StmtCache ¶
type StmtCache struct {
// contains filtered or unexported fields
}
func NewStmtCache ¶
func (*StmtCache) CleanStmtList ¶
func (sc *StmtCache) CleanStmtList()
func (*StmtCache) CleanWasteList ¶
清理wasteList中的stmt 为了防止stmt清理时被其他协程使用,因此wasteList中的stmt一定要超过60秒才能close 若不过过60秒,继续加入到wasteList中,等待下次清理
func (*StmtCache) RemoveOldest ¶
func (sc *StmtCache) RemoveOldest()
cache_list的容量超过max_size时,将陈旧的stmt移到wasteList中 若距离上次清理时间超过指定的值,则启动清理协程
func (*StmtCache) SetStmt ¶
添加一个stmt到从cacheList 若存在,则直接移动到列头,否则添加一个item到cacheList中 若stmt的数量超出max_size,则将最后的stmt移动到wasteList中
func (*StmtCache) TryCleanWasteList ¶
func (sc *StmtCache) TryCleanWasteList()
若距离上次清理时间>30秒,则进行实际清理
type StringPair ¶ added in v1.1.0
type StringRow ¶
func ScanStringRow ¶
type StringRows ¶ added in v1.1.0
func (*StringRows) Scan ¶ added in v1.1.0
func (rows *StringRows) Scan(ent_ptr *StringRow) error
type StringTable ¶
type StringTable struct {
// contains filtered or unexported fields
}
func (*StringTable) GetColCount ¶
func (data *StringTable) GetColCount() int
func (*StringTable) GetColumns ¶
func (data *StringTable) GetColumns() []string
func (*StringTable) GetRowCount ¶
func (data *StringTable) GetRowCount() int
func (*StringTable) GetRowData ¶
func (data *StringTable) GetRowData(r_no int) StringRow
type StructRows ¶ added in v1.1.0
func (*StructRows) Scan ¶ added in v1.1.0
func (rows *StructRows) Scan(ent_ptr interface{}) error
type ValueArray ¶ added in v1.1.2
type ValueArray []KeyVal
Source Files ¶
- db_default.go
- db_engin.go
- db_joint.go
- db_joint_vo.go
- db_model.go
- db_model_batch.go
- db_model_eo.go
- db_model_field.go
- db_model_iud.go
- db_model_query.go
- db_model_rows.go
- db_model_vo.go
- db_policy.go
- db_rows_base.go
- db_rows_string.go
- db_rows_struct.go
- db_scan.go
- db_session.go
- db_sql.go
- db_table.go
- db_where.go
- dialect.go
- dialect_mssql.go
- dialect_mysql.go
- dialect_orcale.go
- dialect_postgres.go
- dialect_sqlite.go
- field_value.go
- hook.go
- kv_data.go
- log_sql.go
- logger.go
- model_pool.go
- model_type.go
- model_value.go
- sql_context.go
- stmt_cache.go
- string_row.go
- test_base.go
- util.go