增加表关联新建功能,同时修复数据库bug
This commit is contained in:
+7
-4
@@ -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...)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user