[ Index ]
 

Code source de CMS made simple 1.0.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/adodb_lite/adodbSQL_drivers/postgres7/ -> postgres7_transaction_module.inc (source)

   1  <?php
   2  /**

   3   * ADOdb Lite Transaction Module for Postgres

   4   * 

   5   */
   6  
   7  eval('class postgres7_transaction_EXTENDER extends '. $last_module . '_ADOConnection { }');
   8  
   9  class postgres7_transaction_ADOConnection extends postgres7_transaction_EXTENDER
  10  {
  11      var $autoCommit = true;
  12      var $transOff = 0;
  13      var $transCnt = 0;
  14      var $transaction_status = true;
  15  
  16  	function StartTrans($errfn = 'ADODB_TransMonitor')
  17      {
  18          if ($this->transOff > 0) {
  19              $this->transOff += 1;
  20              return;
  21          }
  22          $this->transaction_status = true;
  23  
  24          if ($this->debug && $this->transCnt > 0)
  25              ADOConnection::outp("Bad Transaction: StartTrans called within BeginTrans");
  26  
  27          $this->BeginTrans();
  28          $this->transOff = 1;
  29      }
  30  
  31  	function BeginTrans()
  32      {
  33          if ($this->transOff)
  34              return true;
  35  
  36          $this->transCnt += 1;
  37          return @pg_Exec($this->connectionId, "begin");
  38      }
  39  
  40  	function CompleteTrans($autoComplete = true)
  41      {
  42          if ($this->transOff > 1) {
  43              $this->transOff -= 1;
  44              return true;
  45          }
  46          $this->transOff = 0;
  47          if ($this->transaction_status && $autoComplete) {
  48              if (!$this->CommitTrans()) {
  49                  $this->transaction_status = false;
  50                  if ($this->debug)
  51                      ADOConnection::outp("Smart Commit failed");
  52              } else
  53                  if ($this->debug)
  54                      ADOConnection::outp("Smart Commit occurred");
  55          } else {
  56              $this->RollbackTrans();
  57              if ($this->debug)
  58                  ADOCOnnection::outp("Smart Rollback occurred");
  59          }
  60          return $this->transaction_status;
  61      }
  62  
  63  	function CommitTrans($ok=true) 
  64      {
  65          if ($this->transOff)
  66              return true;
  67  
  68          if (!$ok)
  69              return $this->RollbackTrans();
  70  
  71          $this->transCnt -= 1;
  72          return @pg_Exec($this->connectionId, "commit");
  73      }
  74  
  75  	function RollbackTrans()
  76      {
  77          if ($this->transOff)
  78              return true;
  79  
  80          $this->transCnt -= 1;
  81          return @pg_Exec($this->connectionId, "rollback");
  82      }
  83  
  84  	function FailTrans()
  85      {
  86          if ($this->debug) 
  87              if ($this->transOff == 0) {
  88                  ADOConnection::outp("FailTrans outside StartTrans/CompleteTrans");
  89              } else {
  90                  ADOConnection::outp("FailTrans was called");
  91              }
  92          $this->transaction_status = false;
  93      }
  94  
  95  	function HasFailedTrans()
  96      {
  97          if ($this->transOff > 0)
  98              return $this->transaction_status == false;
  99  
 100          return false;
 101      }
 102  
 103  	function RowLock($tables,$where,$flds='1 as ignore') 
 104      {
 105          if (!$this->transCnt)
 106              $this->BeginTrans();
 107  
 108          return $this->GetOne("select $flds from $tables where $where for update");
 109      }
 110  
 111  	function CommitLock($table)
 112      {
 113          return $this->CommitTrans();
 114      }
 115  
 116  	function RollbackLock($table)
 117      {
 118          return $this->RollbackTrans();
 119      }
 120  
 121  }
 122  
 123  eval('class postgres7_transaction_resultset_EXTENDER extends '. $last_module . '_ResultSet { }');
 124  
 125  class postgres7_transaction_ResultSet extends postgres7_transaction_resultset_EXTENDER
 126  {
 127  }
 128  ?>


Généré le : Tue Apr 3 18:50:37 2007 par Balluche grâce à PHPXref 0.7