完善error库
This commit is contained in:
@@ -18,6 +18,7 @@ type HoTimeDB struct {
|
||||
ContextBase
|
||||
*cache.HoTimeCache
|
||||
Type string
|
||||
Prefix string
|
||||
LastQuery string
|
||||
LastData []interface{}
|
||||
ConnectFunc func(err ...*Error) (*sql.DB, *sql.DB)
|
||||
@@ -438,7 +439,7 @@ func (that *HoTimeDB) Select(table string, qu ...interface{}) []Map {
|
||||
query += " *"
|
||||
}
|
||||
|
||||
query += " FROM " + table
|
||||
query += " FROM " + that.Prefix + table
|
||||
|
||||
if join {
|
||||
for k, v := range qu[0].(Map) {
|
||||
@@ -515,6 +516,9 @@ func (that *HoTimeDB) Get(table string, qu ...interface{}) Map {
|
||||
}
|
||||
return data[0]
|
||||
}
|
||||
func (that *HoTimeDB) GetPrefix() string {
|
||||
return that.Prefix
|
||||
}
|
||||
|
||||
// Count 计数
|
||||
func (that *HoTimeDB) Count(table string, qu ...interface{}) int {
|
||||
@@ -853,7 +857,7 @@ func (that *HoTimeDB) cond(tag string, data Map) (string, []interface{}) {
|
||||
// Update 更新数据
|
||||
func (that *HoTimeDB) Update(table string, data Map, where Map) int64 {
|
||||
|
||||
query := "UPDATE " + table + " SET "
|
||||
query := "UPDATE " + that.Prefix + table + " SET "
|
||||
//UPDATE Person SET Address = 'Zhongshan 23', City = 'Nanjing' WHERE LastName = 'Wilson'
|
||||
qs := make([]interface{}, 0)
|
||||
tp := len(data)
|
||||
@@ -898,7 +902,7 @@ func (that *HoTimeDB) Update(table string, data Map, where Map) int64 {
|
||||
|
||||
func (that *HoTimeDB) Delete(table string, data map[string]interface{}) int64 {
|
||||
|
||||
query := "DELETE FROM " + table + " "
|
||||
query := "DELETE FROM " + that.Prefix + table + " "
|
||||
|
||||
temp, resWhere := that.where(data)
|
||||
query += temp
|
||||
@@ -941,7 +945,7 @@ func (that *HoTimeDB) Insert(table string, data map[string]interface{}) int64 {
|
||||
}
|
||||
|
||||
}
|
||||
query := "INSERT INTO " + table + queryString + "VALUES" + valueString
|
||||
query := "INSERT INTO " + that.Prefix + table + queryString + "VALUES" + valueString
|
||||
|
||||
res, err := that.Exec(query, values...)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user