Add replace
This commit is contained in:
parent
1055774a44
commit
f5fd0f9309
12
dbpool.go
12
dbpool.go
@ -130,6 +130,16 @@ func (this *dbPool) Insert(
|
|||||||
this.internalExec(dataSource, sql, params, cb)
|
this.internalExec(dataSource, sql, params, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *dbPool) Replace(
|
||||||
|
dataSource string,
|
||||||
|
tblName string,
|
||||||
|
fieldsKv [][]string,
|
||||||
|
cb ExecResultCb) {
|
||||||
|
params := []string{}
|
||||||
|
sql := "REPLACE INTO `" + tblName + "` " + this.joinInsertFields(fieldsKv, ¶ms)
|
||||||
|
this.internalExec(dataSource, sql, params, cb)
|
||||||
|
}
|
||||||
|
|
||||||
func (this *dbPool) Upsert(
|
func (this *dbPool) Upsert(
|
||||||
dataSource string,
|
dataSource string,
|
||||||
tblName string,
|
tblName string,
|
||||||
@ -274,7 +284,7 @@ func (this *dbPool) joinInsertFields(fieldsKv [][]string, params *[]string) stri
|
|||||||
*params = append(*params, items[1])
|
*params = append(*params, items[1])
|
||||||
}
|
}
|
||||||
sql += ")"
|
sql += ")"
|
||||||
return ""
|
return sql
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *dbPool) internalExec(dataSource string, sql string, params []string,
|
func (this *dbPool) internalExec(dataSource string, sql string, params []string,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user