Database operations - Nested transactions.php 297 Bytes
Newer Older
1

hansbrix's avatar
hansbrix committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<code type="php">
try {
    $conn->beginTransaction();
    
    $user->save();
        
        $conn->beginTransaction();
            $group->save();
            $email->save();
            
        $conn->commit();

    $conn->commit();
} catch(Exception $e) {
    $conn->rollback();
}
</code>