summaryrefslogtreecommitdiff
path: root/app/php/db/DBConnection.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/php/db/DBConnection.php')
-rw-r--r--app/php/db/DBConnection.php33
1 files changed, 33 insertions, 0 deletions
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 @@
+<?php
+
+Prado::using('Application.db.DBTransaction');
+Prado::using('System.Data.TDbConnection');
+
+class DBConnection extends TDbConnection {
+
+ public function __construct($dsn = '', $username = '', $password = '', $charset = '') {
+ $this->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;
+ }
+
+}
+
+?>