Does php transaction control need to be controlled like this? If ($ sql1 & amp; $ sql2 & amp; $ sql3) {code ...}} as a result, there are many SQL statements, and the if condition will be many $ sql1 & amp; $ sql2. How do different functions control transactions? Does php transaction control need to be controlled like this?
If ($ sql1 & $ sql2 & $ sql3)
{
$tranDb->commit();
}
As a result, there are more SQL statements, and the if condition will be many $ sql1 & $ sql2. How do I control transactions between different functions?
Reply content:
Does php transaction control need to be controlled like this?
If ($ sql1 & $ sql2 & $ sql3)
{
$tranDb->commit();
}
As a result, there are more SQL statements, and the if condition will be many $ sql1 & $ sql2. How do I control transactions between different functions?
The transaction or transaction rollback should be committed by capturing exceptions.
If (! $ Sql1 ){
$ Db-> rollback ();
}
If (! $ Sql2 ){
$ Db-> rollback ();
}
If (! $ Sql3 ){
$ Db-> rollback ();
}
$ Db-> comit ();
That is, submit the job after it is all successful. Roll back if it fails. I hope you can understand it!
The upstairs looks clear, but there are too many redundancy. The topic is well written. I have already written this article.