I have several model functions that are executed before the transaction is completed. for instance
$this->model_A->insert('....'); $this->model_C->insert('....'); $this->model_D->insert('....'); $this->model_E->update('....');
What is the best way to use trans_start () and trans_complete (), so the insert or update process is interrupted at any time when the transaction can be rolled back or executed accordingly ...
Is it possible to use these lines below in my controller? Like this?
$this->db->trans_start(); $this->model_A->insert('....'); $this->model_C->insert('....'); $this->model_D->insert('....'); $this->model_E->update('....'); $this->db->trans_complete(); OR $this->model_A->trans_start(); $this->model_A->insert('....'); $this->model_C->insert('....'); $this->model_D->insert('....'); $this->model_E->update('....'); $this->model_A->trans_complete();
Is it good practice, if not the best way to handle such transactions?
source share