Yii Framework Forum: Nested DB transactions - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Nested DB transactions PDO save transactions Rate Topic: -----

#1 User is offline   gjerokrsteski 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 05-September 12
  • Location:Germany - Köln

Posted 07 September 2012 - 02:09 AM

This is dedicated to foolowing posting: http://www.yiiframew...sql#add-comment "How to use nested DB transactions (MySQL 5+, PostgreSQL)"

I just have extended the method "public function rollBack()".

This check avoids the user from trying to rollback an transaction without a transaction-start.

  
...
..
/**
   * @return bool|void
   * @throws PDOException
   */
  public function rollBack()
  {
    if ($this->transLevel == 0) {
      throw new PDOException(
        'trying to rollback without a transaction-start'
      );
    }

    $this->transLevel--;

    if ($this->transLevel == 0 || !$this->nestable()) {
      parent::rollBack();
    } else {
      $this->exec("ROLLBACK TO SAVEPOINT LEVEL{$this->transLevel}");
    }
  }

...
..

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users