[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 /** 3 * ADOdb Lite Transaction Module for Sqlite 4 * 5 */ 6 7 eval('class sqlite_transaction_EXTENDER extends '. $last_module . '_ADOConnection { }'); 8 9 class sqlite_transaction_ADOConnection extends sqlite_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 $ret = $this->Execute("BEGIN TRANSACTION"); 37 $this->transCnt += 1; 38 return true; 39 } 40 41 function CompleteTrans($autoComplete = true) 42 { 43 if ($this->transOff > 1) { 44 $this->transOff -= 1; 45 return true; 46 } 47 $this->transOff = 0; 48 if ($this->transaction_status && $autoComplete) { 49 if (!$this->CommitTrans()) { 50 $this->transaction_status = false; 51 if ($this->debug) 52 ADOConnection::outp("Smart Commit failed"); 53 } else 54 if ($this->debug) 55 ADOConnection::outp("Smart Commit occurred"); 56 } else { 57 $this->RollbackTrans(); 58 if ($this->debug) 59 ADOCOnnection::outp("Smart Rollback occurred"); 60 } 61 return $this->transaction_status; 62 } 63 64 function CommitTrans($ok=true) 65 { 66 if ($this->transOff) 67 return true; 68 69 if (!$ok) 70 return $this->RollbackTrans(); 71 72 $ret = $this->Execute("COMMIT"); 73 if ($this->transCnt>0) 74 $this->transCnt -= 1; 75 76 return !empty($ret); 77 } 78 79 function RollbackTrans() 80 { 81 if ($this->transOff) 82 return true; 83 84 $ret = $this->Execute("ROLLBACK"); 85 if ($this->transCnt>0) 86 $this->transCnt -= 1; 87 88 return !empty($ret); 89 } 90 91 function FailTrans() 92 { 93 if ($this->debug) 94 if ($this->transOff == 0) { 95 ADOConnection::outp("FailTrans outside StartTrans/CompleteTrans"); 96 } else { 97 ADOConnection::outp("FailTrans was called"); 98 } 99 $this->transaction_status = false; 100 } 101 102 function HasFailedTrans() 103 { 104 if ($this->transOff > 0) 105 return $this->transaction_status == false; 106 107 return false; 108 } 109 110 function RowLock($tables,$where,$flds='1 as ignore') 111 { 112 return false; 113 } 114 115 function CommitLock($table) 116 { 117 return $this->CommitTrans(); 118 } 119 120 function RollbackLock($table) 121 { 122 return $this->RollbackTrans(); 123 } 124 125 } 126 127 eval('class sqlite_transaction_resultset_EXTENDER extends '. $last_module . '_ResultSet { }'); 128 129 class sqlite_transaction_ResultSet extends sqlite_transaction_resultset_EXTENDER 130 { 131 } 132 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |