diff --git a/dbpool.go b/dbpool.go index 1414b75..b18c4fc 100644 --- a/dbpool.go +++ b/dbpool.go @@ -130,6 +130,16 @@ func (this *dbPool) Insert( 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( dataSource string, tblName string, @@ -274,7 +284,7 @@ func (this *dbPool) joinInsertFields(fieldsKv [][]string, params *[]string) stri *params = append(*params, items[1]) } sql += ")" - return "" + return sql } func (this *dbPool) internalExec(dataSource string, sql string, params []string,