All pastes #2045162 Raw Edit

Unnamed

public php v1 · immutable
#2045162 ·published 2011-04-11 16:58 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($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();	}}?>