This sounds like a pretty basic AND
use case. Since you're in PHP, you're not worried about asyncronous calls or timeout waits. To pseudocode it:
Start Transaction1
... do stuff... //transaction 1 still open, no commit
Start Transaction2
... do more stuff...
If (Transaction1 success && Transaction2 success) {
commit Transaction1
commit Transaction2
} else {
rollback Transaction1
rollback Transaction2
}