From b6ad16cbd2092d76d4fed03d37a77d29b5b38f00 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 26 Feb 2016 14:59:34 +0100 Subject: * database connection setup in PHP app --- app/php/db/DBConnection.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 app/php/db/DBConnection.php (limited to 'app/php/db/DBConnection.php') diff --git a/app/php/db/DBConnection.php b/app/php/db/DBConnection.php new file mode 100644 index 0000000..4fb18c8 --- /dev/null +++ b/app/php/db/DBConnection.php @@ -0,0 +1,33 @@ +setTransactionClass('Application.Code.DBTransaction'); + parent::__construct($dsn, $username, $password, $charset); + } + + private $_transaction = NULL; + public function getCurrentTransaction() { + if (!$this->_transaction->getActive()) { + $this->_transaction = NULL; + } + return $this->_transaction; + } + + public function beginTransaction() { + if ($this->_transaction && $this->_transaction->getActive()) { + $this->_transaction->beginNestedTransaction(); + } + else { + $this->_transaction = parent::beginTransaction(); + } + return $this->_transaction; + } + +} + +?> -- cgit v1.2.3