Show
Ignore:
Timestamp:
10/02/08 01:00:33 (3 months ago)
Author:
nowelium
Message:

fix:procedure & transaction scripts

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/php/misc/Hermit/src/Hermit/tx/AbstractHermitTx.php

    r20152 r20417  
    77    private $txRule = array(); 
    88    private $connection; 
    9     public function hasTransaction(){ 
     9    private $begin = false; 
     10    public final function hasTransaction(){ 
     11        if($this->begin){ 
     12            return true; 
     13        } 
     14        return $this->begin = $this->connection->beginTransaction(); 
    1015    } 
    11     public function begin(){ 
     16    public final function begin(){ 
     17        try { 
     18            if(!$this->begin){ 
     19                $this->begin = $this->connection->beginTransaction(); 
     20            } 
     21        } catch(Exception $e){ 
     22            // TODO: Nest transaction 
     23            throw $e; 
     24        } 
    1225    } 
    13     public function commit(){ 
     26    public final function commit(){ 
     27        try { 
     28            if($this->connection->commit()){ 
     29                $this->begin = false; 
     30            } 
     31        } catch(Exception $e){ 
     32            throw $e; 
     33        }     
    1434    } 
    15     public function rollback(){ 
     35    public final function rollback(){ 
     36        try { 
     37            if ($this->hasTransaction()) { 
     38                return $this->connection->rollback(); 
     39            } 
     40        } catch(Exception $e){ 
     41            throw $e; 
     42        } 
    1643    } 
    17     public function suspend(){ 
     44    public final function suspend(){ 
     45        return $this->connection; 
    1846    } 
    19     public function resume(PDO $connection){ 
     47    public final function resume(PDO $connection){ 
     48        $this->connection = $connection; 
    2049    } 
    2150    public final function complete(Exception $e){