控制中的Codeigniter事务

Since I have several functions executing in the following control as a single transaction I couldn't surround each function as a transaction in the model. So I did it the following way. Please someone let me know if there is any problem. Works fine for now, but have no idea whether it will get any concurrency issues or there is any other way?

if(isset($_POST['btnsave']))
        {
            $mcodes = $_POST['tblmcode'];
            $count = count($mcodes);
            //echo $count;

            $issue = new Materialissue_model();

            $this->db->trans_start(); //Here starts my transaction
            $issue->setIssuecode($this->input->post('txtissuecode'));

            if($issue->checkNoExistence()) {

                $issue->setDate($this->input->post('txtdate'));
                $issue->setCustomer($this->input->post('txtcustomer'));
                $issue->setFromlocation($this->input->post('txtlocation'));
                $issue->setResponsible($this->input->post('txtresponsible'));
                $issue->setComments($this->input->post('txtcomments'));
                $issue->setTotal($this->input->post('txttotal'));
                $issue->setUser($this->session->userdata('username'));
                $issue->setStatus($this->input->post('txtstatus'));

                for ($i = 0; $i < $count; $i++) {

                    $issue->setMaterialcode($_POST['tblmcode'][$i]);
                    $issue->setMaterialname($_POST['tblmname'][$i]);
                    $issue->setCost($_POST['tblcost'][$i]);
                    $issue->setQty($_POST['tblqty'][$i]);
                    $issue->setSubtotal($_POST['tblsubtotal'][$i]);
                    $issue->saveIssueDetail();

                    $stock = new Materialstock_model();
                    $stock->setItemcode($_POST['tblmcode'][$i]);
                    $stock->setItemlocation($this->input->post('txtlocation'));
                    $stock->setQty($_POST['tblqty'][$i]);
                    $stock->setRefno($this->input->post('txtissuecode'));
                    $stock->setLasttransaction('MATERIAL-ISSUE');
                    $stock->updateMaterialIssueStock();


                    $transaction = new Transaction_model();
                    $transaction->setDescription("MATERIAL-ISSUE");
                    $transaction->setItemcode($_POST['tblmcode'][$i]);
                    $transaction->setRecqty("0");
                    $transaction->setTransqty("0");
                    $transaction->setIssueqty($_POST['tblqty'][$i]);
                    $transaction->setDate($this->input->post('txtdate'));
                    $transaction->setUser($this->session->userdata('username'));
                    $transaction->saveMaterialTransaction();


                }

                $result = $issue->saveIssue();
                $this->db->trans_complete(); //Here ends my transaction
                if ($result) {

                    $message = new Message_model();
                    $data['message'] = $message->recordadded;
                    $data['type'] = "success";
                    $data['returnpage'] = base_url() . "index.php/materialissue_control/show";
                    $data["print"] =  base_url() . "index.php/Notegenerator_control/showMaterialIssueNote?code=".$issue->getIssuecode();
                    $this->load->view('messageprint_view', $data);

                }

            }else{

                $message = new Message_model();
                $data['message'] = $message->issuecodeexists;
                $data['type'] = "error";
                $data['returnpage'] = base_url() . "index.php/materialissue_control/show";
                $this->load->view('message_view', $data);


            }

        }

I prefer like using trigger to handle many functions in one controller, this make mycode clean and easy to track. example: user writes article, this action will call one action in model write_article combine with 1 transaction, but this function run any query : 1.insert post 2.lock count post category 3.lock count user post 4.lock count post by date example in code

public function write_article($post) {
    $this->cms->db->trans_start(TRUE);
        $this->cms->db->set('content', $posts->get_content());
        $this->cms->db->insert('t_posts');
    $this->cms->db->trans_complete();
    if($this->cms->db->trans_status() === TRUE){
        $this->cms->db->trans_commit();
    }else{
        $this->cms->db->trans_rollback();
    }
}

This reference about trigger www.sitepoint.com/how-to-create-mysql-triggers