【发布时间】:2020-03-29 03:37:26
【问题描述】:
我有一个嵌套事务,用于提交几个不同的表。我只想在嵌套中提交一个表,在外部提交中提交另外两个表。
beginTransaction();
error_message.=function A();
error_message.=function B();
if (empty error_message){
commit(); //commit table B and C
} else {
rollback();
}
function A(){
beginTransaction();
update table A //wants to commit table A immediately
commit();
//do some stuff
update table B
if(error) {
return error_message
} else {
return null
}
}
function B(){
beginTransaction();
update table A //wants to commit table A immediately
commit();
//do some stuff
update table C
if(error) {
return error_message
} else {
return null
}
}
【问题讨论】:
标签: mysql database laravel transactions database-connection