1/*
2* Start transaction scope
3*/
4$conn->beginTrans();
5
6/*
7* Execute some insert or update SQL
8*/
9$ok = $conn->execute($sql);
10
11if ($ok) {
12 /*
13 * The previous execution succeeded, do some more
14 */
15 $ok = $conn->execute($sql2);
16} else {
17 /*
18 * Branch, do some other work, then return
19 */
20}
21
22if (!$ok) {
23 /*
24 * Test the last insertion, if not successful roll
25 * back the entire transaction scope
26 */
27 $conn->rollbackTrans();
28} else {
29 /*
30 * Go ahead and commit
31 */
32 $conn->commitTrans();
33}