Difference between #4 and #5 of
How to use nested DB transactions (MySQL 5+, PostgreSQL)

Revision #5 has been created by samdark on Aug 6, 2011, 7:15:03 PM with the memo:

Optimized code
« previous (#4) next (#6) »

Changes

Title unchanged

How to use nested DB transactions (MySQL 5+, PostgreSQL)

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

db, mysql, postgresql, transaction, nested

Content changed

SOriginal source code takenand idea are from: [PHP, PDO & Nested Transactions](http://www.kennynet.co.uk/2008/12/02/php-pdo-nested-transactions/).

Tested with: MySQL 5.1.30 + Yii 1.1.8.
[...]
public function beginTransaction() {
if(
!$this->nestable() || $this->transLevel == 0 || !$this->nestable()) {
parent::beginTransaction();
} else {
[...]
$this->transLevel--;

if(
!$this->nestable()transLevel == 0 || !$this->transLevel == 0nestable()) {
parent::commit();
} else {
[...]
$this->transLevel--;

if(
!$this->nestable() || $this->transLevel == 0 || !$this->nestable()) {
parent::rollBack();
} else {
$this->exec("ROLLBACK TO SAVEPOINT LEVEL{$this->transLevel}");
}
}
[...]
41 0
26 followers
Viewed: 46 420 times
Version: 1.1
Category: How-tos
Written by: mindeh
Last updated by: Boaz
Created on: Jun 30, 2009
Last updated: 2 years ago
Update Article

Revisions

View all history