All pastes #2045171 Raw Edit

Unnamed

public php v1 · immutable
#2045171 ·published 2011-04-11 17:09 UTC
rendered paste body
<?phpclass dtc{	protected static $instance = null;		public static function get_instance()	{		if(is_null(dtc::$instance)) dtc::$instance = new dtc();		return dtc::$instance;	}		protected $in_tx;	protected $obj;		protected function __construct()	{		$this->in_tx = false;		$this->obj = array();	}		public function in_tx()	{		return $this->in_tx;	}		public function register(transactable  $obj)	{		$this->obj[] = $obj;	}		public function begin()	{		$this->in_tx = true;		foreach($this->obj as $v) $v->begin();	}		public function commit()	{		$this->in_tx = false;		foreach($this->obj as $v) $v->commit();	}	public function rollback()	{		$this->in_tx = false;		foreach($this->obj as $v) $v->rollback();	}}interface transactable {		public function begin();	public function commit();	public function rollback();}?>