无论使用哪种方式,都应该注意到,只有通过TxOrm执行的 SQL 才会被认为是在一个事务里面。
o := orm.NewOrm()
to, err := o.Begin()
// Outside the txn
o.Insert(xxx)
// Inside the txn
to.Insert(xxx)
to.commit()
无论使用哪种方式,都应该注意到,只有通过TxOrm执行的 SQL 才会被认为是在一个事务里面。
o := orm.NewOrm()
to, err := o.Begin()
// Outside the txn
o.Insert(xxx)
// Inside the txn
to.Insert(xxx)
to.commit()