Code Analysis of open transactions under CI framework

Source: Internet
Author: User
This article introduces to you the content of the CI framework to open the transaction code analysis, there is a certain reference value, the need for friends can refer to, I hope you have some help.

<?php//open transaction, CI framework $this->systems_model->base_connect (); $this->systems_model->db->initialize (); $this->systems_model->db->trans_begin (); try {$rs = $this->systems_model->update ($data, $condition, '    User ', false);    if (! $rs) {throw new Exception ("User Information modification failed"); } if ($rs) {//delete the corresponding ID data in the User Role intermediate table is reinserted $delRes = $this->systems_model->delete_user_role ($id        );                if ($delRes) {foreach ($roles as $k = + $v) {$roleData [' iuserid '] = $id;                $roleData [' sroleid '] = $v;            $res = $this->systems_model->save ($act, $roleData, ' User_role ', false);        }} else {throw new Exception ("Change the original role failed"); if ($res) {if ($this->systems_model->db->trans_status () = = = FALSE) {$this-&G T            Systems_model->db->trans_rollback (); } else {$this->systems_model->db->trans_comMIT ();            } getpower (TRUE);//The user rights of the login will be updated after the successful modification $this->systems_model->base_close ();        Outprintapijson (0, ' modified successfully ');        } else {throw new Exception ("Modify role failed");    }}} catch (Exception $e) {$this->systems_model->db->trans_rollback ();    $this->systems_model->base_close ();    $msg = $e->getmessage ();    Outprintapijson (1, $msg); Exit;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.