Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Multiple groups of transactions
  • The FuelPHP supports multiple groups of transactions? How to use?

    I tried that...

    public static function trans_test1()
    {
    try
    {
    DB::start_transaction();

    $query1 = DB::query("INSERT INTO users (`login`, `password`) VALUES ('test', '123')")->execute();
    $query2 = self::trans_test2();

    DB::commit_transaction();

    return $query1;
    }
    catch (Exception $e)
    {
    DB::rollback_transaction();

    throw $e;
    }
    }

    public static function trans_test2()
    {
    try
    {
    DB::start_transaction();

    $query2 = DB::query('SELECT * FROM `users`')->execute();

    DB::commit_transaction();

    return $query2;
    }
    catch (Exception $e)
    {
    DB::rollback_transaction();

    throw $e;
    }
    }


    but generated the error:
    PDOException [ Error ]:
    There is no active transaction

    COREPATH/classes/database/pdo/connection.php @ line 474
  • HarroHarro
    Accepted Answer
    Not in the current release.

    And note that not all databases support nested transactions. Which is a problem because currently we have a generic PDO driver, instead of platform specific drivers. Which makes implementing platform specific code near to impossible.

    There has been a PR for 1.8/develop, where nested transactions are simulated using savepoints (https://github.com/fuel/core/pull/1610) but it hasn't been validated and merged yet.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion