Posted by vijinho on Thu 10 Apr 15:17
report abuse | download | new post
- <?php
- /**
- * Fail Default Database Class
- *
- * @package Fail
- * @author Vijay Mahrra
- * @copyright (c) 2008 Fail (UK) Limited
- */
- class Database extends Database_Core {
- /**
- * Transaction status variable
- *
- * @var in_transaction
- */
- protected $in_transaction = false;
- public function __construct()
- {
- parent::__construct();
- }
- public function __destruct()
- {
- self::trans_rollback();
- }
- /**
- * Status of transaction
- *
- * @return void
- */
- public function trans_status()
- {
- return $this->in_transaction;
- }
- /**
- * Start a transaction
- *
- * @return void
- */
- public function trans_start()
- {
- if ($this->in_transaction === false) {
- $this->query('SET AUTOCOMMIT=0');
- $this->query('BEGIN');
- }
- $this->in_transaction = true;
- }
- /**
- * Finish the transaction
- *
- * @return void
- */
- public function trans_complete()
- {
- if ($this->in_transaction === true) {
- $this->query('COMMIT');
- $this->query('SET AUTOCOMMIT=1');
- }
- $this->in_transaction = false;
- }
- /**
- * Undo the transaction
- *
- * @return void
- */
- public function trans_rollback()
- {
- if ($this->in_transaction === true) {
- $this->query('ROLLBACK');
- $this->query('SET AUTOCOMMIT=1');
- }
- $this->in_transaction = false;
- }
- }
- ?>
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.