From 14f6e5fc28aa707af9dbc1b7db627f88825ba3bb Mon Sep 17 00:00:00 2001 From: loshiqi <553578653@qq.com> Date: Tue, 3 Jun 2025 16:32:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=A7=E8=A1=8C=E5=8E=9F?= =?UTF-8?q?=E5=A7=8B=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- transaction_chain.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/transaction_chain.go b/transaction_chain.go index d024c4a..cce1127 100644 --- a/transaction_chain.go +++ b/transaction_chain.go @@ -877,6 +877,26 @@ func (this *TxQuery) CreateAll() (int64, error) { return StmtForInsertExec(this.stmt, this.value) } +/** + * 执行原生sql + * return error + */ +func (this *TxQuery) ExecSql(sql string) (int64, error) { + if this.debug { + log.Println("ExecSql sql:", sql) + } + stmt, err = this.tx.Prepare(sql) + + if err != nil { + return 0, err + } + res, err := stmt.Exec() + if err != nil { + return 0, errors.New("执行失败:" + err.Error()) + } + return res.RowsAffected() +} + /** * 提交 */