1
0
mirror of synced 2024-12-15 15:46:02 +03:00
doctrine2/manual/codes/Transactions - Nesting.php

24 lines
462 B
PHP

<?php
function saveUserAndGroup(Doctrine_Connection $conn, User $user, Group $group) {
$conn->beginTransaction();
$user->save();
$group->save();
$conn->commit();
}
try {
$conn->beginTransaction();
saveUserAndGroup($conn,$user,$group);
saveUserAndGroup($conn,$user2,$group2);
saveUserAndGroup($conn,$user3,$group3);
$conn->commit();
} catch(Doctrine_Exception $e) {
$conn->rollback();
}
?>