1
0
mirror of synced 2024-12-13 14:56:01 +03:00
doctrine2/manual/codes/Transactions - Nesting.php

24 lines
462 B
PHP
Raw Normal View History

2006-07-24 01:08:06 +04:00
<?php
function saveUserAndGroup(Doctrine_Connection $conn, User $user, Group $group) {
$conn->beginTransaction();
2006-07-24 01:08:06 +04:00
$user->save();
2006-07-24 01:08:06 +04:00
$group->save();
$conn->commit();
2006-07-24 01:08:06 +04:00
}
try {
$conn->beginTransaction();
2006-07-24 01:08:06 +04:00
saveUserAndGroup($conn,$user,$group);
saveUserAndGroup($conn,$user2,$group2);
saveUserAndGroup($conn,$user3,$group3);
2006-07-24 01:08:06 +04:00
$conn->commit();
2006-07-24 01:08:06 +04:00
} catch(Doctrine_Exception $e) {
$conn->rollback();
2006-07-24 01:08:06 +04:00
}
?>