增加表关联新建功能,同时修复数据库bug

This commit is contained in:
2021-08-28 13:05:12 +08:00
parent 47b28e7b57
commit 09b1d37ae3
23 changed files with 193 additions and 88 deletions
+7 -4
View File
@@ -440,8 +440,11 @@ func (that *HoTimeDB) Select(table string, qu ...interface{}) []Map {
} else {
query += " *"
}
query += " FROM " + that.Prefix + table
if !strings.Contains(table, ".") && !strings.Contains(table, " AS ") {
query += " FROM `" + that.Prefix + table + "`"
} else {
query += " FROM " + that.Prefix + table
}
if join {
for k, v := range qu[0].(Map) {
@@ -919,7 +922,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 " + that.Prefix + 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)
@@ -1007,7 +1010,7 @@ func (that *HoTimeDB) Insert(table string, data map[string]interface{}) int64 {
}
}
query := "INSERT INTO " + that.Prefix + table + queryString + "VALUES" + valueString
query := "INSERT INTO `" + that.Prefix + table + "` " + queryString + "VALUES" + valueString
res, err := that.Exec(query, values...)