/[drupal]/contributions/modules/pressflow_transaction/pressflow_transaction.module
ViewVC logotype

Contents of /contributions/modules/pressflow_transaction/pressflow_transaction.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download) (as text)
Mon Jun 4 08:27:21 2007 UTC (2 years, 5 months ago) by straussd
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -1 lines
File MIME type: text/x-php
fix bug
1 <?php
2 class pressflow_transaction {
3 private static $layers = 0;
4 private static $allow_commit = TRUE;
5
6 function __construct()
7 {
8 if (self::$layers == 0)
9 db_query('BEGIN');
10 self::$layers++;
11 }
12
13 function __destruct()
14 {
15 self::$layers--;
16 if (self::$layers == 0) {
17 if (self::$allow_commit) {
18 db_query('COMMIT');
19 } else {
20 db_query('ROLLBACK');
21 }
22 // Reset the ROLLBACK propagator
23 self::$allow_commit = TRUE;
24 }
25 }
26
27 public function rollback_if_false($var)
28 {
29 if ($var === FALSE) {
30 $this->rollback();
31 }
32 }
33
34 public function rollback()
35 {
36 self::$allow_commit = FALSE;
37 }
38
39 static public function will_rollback()
40 {
41 return !self::$allow_commit;
42 }
43 }

  ViewVC Help
Powered by ViewVC 1.1.2