Nested DB transactions

This is dedicated to foolowing posting: http://www.yiiframework.com/wiki/38/how-to-use-nested-db-transactions-mysql-5-postgresql#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}");

    }

  }


...

..