|
@ -155,11 +155,10 @@ func (this *TxQuery) Clean() *TxQuery { |
|
|
return this |
|
|
return this |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 拼查询sql
|
|
|
|
|
|
func (this *TxQuery) QueryStmt() error { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//构造子查询
|
|
|
|
|
|
func (this *TxQuery) BuildSelectSql() (map[string]interface{}, error) { |
|
|
if this.dbname == "" && this.table == "" { |
|
|
if this.dbname == "" && this.table == "" { |
|
|
return errors.New("参数错误,没有数据表") |
|
|
|
|
|
|
|
|
return nil, errors.New("参数错误,没有数据表") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
table := getTableName(this.dbname, this.table) |
|
|
table := getTableName(this.dbname, this.table) |
|
@ -238,8 +237,23 @@ func (this *TxQuery) QueryStmt() error { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if condition_len != len(this.value) { |
|
|
if condition_len != len(this.value) { |
|
|
return errors.New("参数错误,条件值错误") |
|
|
|
|
|
|
|
|
return nil, errors.New("参数错误,条件值错误") |
|
|
|
|
|
} |
|
|
|
|
|
return map[string]interface{}{ |
|
|
|
|
|
"sql": sql, |
|
|
|
|
|
"value": this.value, |
|
|
|
|
|
}, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 拼查询sql
|
|
|
|
|
|
func (this *TxQuery) QueryStmt() error { |
|
|
|
|
|
|
|
|
|
|
|
res := map[string]interface{}{} |
|
|
|
|
|
res, err = this.BuildSelectSql() |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
sql := helper.ToStr(res["sql"]) |
|
|
|
|
|
|
|
|
stmt, err = this.tx.Prepare(sql + " FOR UPDATE") |
|
|
stmt, err = this.tx.Prepare(sql + " FOR UPDATE") |
|
|
|
|
|
|
|
|