Changeset:
0b445cca4b04
https://sourceforge.net/p/mrbs/hg-code/ci/0b445cca4b04ed17df4044ed2b582a3fa76998d1
Author:
Campbell Morrison <[email protected]>
Date:
Wed Apr 05 22:25:56 2017 +0100
Log message:
Altered transaction methods to use PDO transaction methods.
diffstat:
web/lib/MRBS/DB.php | 9 +++------
web/lib/MRBS/DB_mysql.php | 14 ++++----------
web/lib/MRBS/DB_pgsql.php | 14 ++++----------
3 files changed, 11 insertions(+), 26 deletions(-)
diffs (99 lines):
diff -r e9376b765aa2 -r 0b445cca4b04 web/lib/MRBS/DB.php
--- a/web/lib/MRBS/DB.php Wed Apr 05 20:28:52 2017 +0100
+++ b/web/lib/MRBS/DB.php Wed Apr 05 22:25:56 2017 +0100
@@ -189,22 +189,19 @@
//
public function begin()
{
- // This method must be extended by the sub-classes, which must call the
parent as the
- // first thing they do. It only exists here in the parent class in order
that all the
- // calls to mrbs_ignore_user_abort() are grouped together.
-
// Turn off ignore_user_abort until the transaction has been committed or
rolled back.
// See the warning at
http://php.net/manual/en/features.persistent-connections.php
// (Only applies to persistent connections, but we'll do it for all cases
to keep
// things simple)
mrbs_ignore_user_abort(TRUE);
+ $this->dbh->beginTransaction();
}
// Commit (end) a transaction. See begin().
public function commit()
{
- $result = $this->command("COMMIT");
+ $this->dbh->commit();
mrbs_ignore_user_abort(FALSE);
}
@@ -212,7 +209,7 @@
// Roll back a transaction, aborting it. See begin().
public function rollback()
{
- $result = $this->command("ROLLBACK", array());
+ $this->dbh->rollBack();
mrbs_ignore_user_abort(FALSE);
}
diff -r e9376b765aa2 -r 0b445cca4b04 web/lib/MRBS/DB_mysql.php
--- a/web/lib/MRBS/DB_mysql.php Wed Apr 05 20:28:52 2017 +0100
+++ b/web/lib/MRBS/DB_mysql.php Wed Apr 05 22:25:56 2017 +0100
@@ -31,15 +31,6 @@
}
- // Begin a transaction, if the database supports it. This is used to
- // improve performance for multiple insert/delete/updates.
- public function begin()
- {
- parent::begin();
- $result = $this->command("START TRANSACTION");
- }
-
-
// Acquire a mutual-exclusion lock on the named table. For portability:
// This will not lock out SELECTs.
// It may lock out DELETE/UPDATE/INSERT or not, depending on the
implementation.
@@ -107,7 +98,10 @@
}
// Rollback any outstanding transactions
- $this->rollback();
+ if ($this->dbh->inTransaction())
+ {
+ $this->rollback();
+ }
}
diff -r e9376b765aa2 -r 0b445cca4b04 web/lib/MRBS/DB_pgsql.php
--- a/web/lib/MRBS/DB_pgsql.php Wed Apr 05 20:28:52 2017 +0100
+++ b/web/lib/MRBS/DB_pgsql.php Wed Apr 05 22:25:56 2017 +0100
@@ -62,15 +62,6 @@
return $this->dbh->lastInsertId($seq_name);
}
-
- // Begin a transaction, if the database supports it. This is used to
- // improve performance for multiple insert/delete/updates.
- public function begin()
- {
- parent::begin();
- $result = $this->command("BEGIN");
- }
-
// Acquire a mutual-exclusion lock on the named table. For portability:
// This will not lock out SELECTs.
@@ -124,7 +115,10 @@
}
// Rollback any outstanding transactions
- $this->rollback();
+ if ($this->dbh->inTransaction())
+ {
+ $this->rollback();
+ }
}
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits