Search code examples
phpmysqlcodeigniterphpmyadminhmvc

In PHP / CodeIgniter more than one transaction started without completing the other; Such as nested transaction


I am using HMVC in Codeigniter
Which have model of inv_module and one is common model

Firstly the $this->inv_module->model stores some data in the database, with the mysql transaction;
then modal call of the $this->common->modal before the transaction is complete of $this->inv_module->model, there is also a mysql transaction.

Can anyone tell me that what will happen when my first transaction is not completed and the transaction of the common model is start ?

my situation like this -

$this->db->trans_start();
$this->db->insert('tbl_categories', $category_array);

    $this->db->trans_start();
        $this->CI->db->insert('tbl_macro',$macro_array);
    $this->db->trans_complete();

$this->db->trans_complete();

This code call from another model -

$this->db->trans_start();
    $this->CI->db->insert('tbl_macro',$macro_array);
$this->db->trans_complete();

please any one help me


Solution

  • The nested transaction will commit or fail only on itself.

    The "outer" transaction will still be valid.