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

Comparing #4 with #5

Revision #5 was created by samdark samdark on Aug 6, 2011, 7:15:03 PM.

Optimized code

Content

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}");
}
}
[...]