summaryrefslogtreecommitdiff
path: root/app/php/db/DBConnection.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-02-26 14:59:34 +0100
committeremkael <emkael@tlen.pl>2016-02-26 14:59:34 +0100
commitb6ad16cbd2092d76d4fed03d37a77d29b5b38f00 (patch)
tree437bb2efbce01724cde04320edfb61d3e6fade93 /app/php/db/DBConnection.php
parent16b4dda0f1d2df3a280b6507e12fe381ba0e8e74 (diff)
* database connection setup in PHP app
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;
+ }
+
+}
+
+?>