Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Regarding transaction
  • Hello sir,

    I have a question regarding transaction.

    I have 2 db configurations and need to access all of  them all the time.

    So, in this case, is following correct?

        $model = \Model_Base::query()->order_by('id', 'desc')->get_one(); 
        $model->data = '1000';
            throw new Exception('Error1');
        $model = \Model_Base::query()->order_by('id', 'desc')->get_one(); 
        $model->data = '2000';
            throw new Exception('Error2');
    catch(Exception $e)

  • What database are you using?

    Not all support distributed transactions across databases, and if they do, they only support it in specific circumstances. Distributed transactions is something you would want to avoid.

    The standard SQL command TRANSACTION, implemented by DB, only works for transactions within a single database.

    If you need distributed transactions, read up on XA transactions. They are very specific depending on the platform you are using, and currently not implemented in the DB drivers.
  • Thanks for quick reply.

    They are MySQL and innoDB is used.

    Also, they are running on the same server.
  • HarroHarro
    Accepted Answer
    It is not relevant if they are on the same server, it is relevant if both connections point to the same or to different databases.

  • Okay thanks for that.
    I tried nested transaction and it seems fine.

Howdy, Stranger!

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

In this Discussion