The use of Try catch in thinkphp

Source: Internet
Author: User

1  Public functionDoedit_set () {2     $info=$this->_post ("Info"); 3     $id=$this->_post ("id");//dump ($info); exit ();4     $user=DD ("Order.orderpackage")->deal_account ($info[' Accounts ']); 5     Try{6         $result=DD (' Set.userset ')->doedit_setinfo ($id,$info,$user);7         if($result){8            $this->success ("Edit succeeded", U ("Userset/index"));9         }Ten         $this->error ("Edit Failed");  One}Catch(Exception $e){     A        $this->error ($e-getMessage ()); -     }     - } the  -  -  -  Public functionDoedit_setinfo ($id,$edit _info,$user _id) + { -    if($id&&$edit _info) +    {      A         $res=m (' User_set ')->where (Array(' op_name ' =$edit _info[' Op_name '], ' id ' = =$id)),find (); at  -         if(!$res) -         { -E ("Illegal data"); -         } -  in         $MD=NewModel (); -         $MD-Starttrans (); to         $user _info=DD ("User.adminuser")get_info (); +         $edit _info[' Start_time ']=Strtotime($edit _info[' Time1 ']); -         $edit _info[' End_time ']=Strtotime($edit _info[' Time2 ']); the         foreach($user _id  as $key=$value) { *  $             $op=m (' User_set ')->where (Array(' op_name ' =$edit _info[' Op_name '], ' uid ' =$value)),find ();Panax Notoginseng             if($op[' ID ']!=$id&&$op ) -             { theE ("This user Configuration already exists"); +             } A  the             if(M (' User_set ')->where (' uid=%d '),$value),find ()) +             {    -                 $edit _info[' UID ']=$value; $                 $result=m (' User_set ')->where ("id=%d",$id)->save ($edit _info); $                 $content= "ID:".$id." |op_name before the modification: ".$res[' Op_name ']. "| Op_value: ".$res[' Op_value ']. "| Op_des: ".$res[' Op_des ']. "| Start_time: ".$res[' Start_time ']. "| End_time: ".$res[' End_time ']. "| Is_del: ".$res[' Is_del ']. "| UID: ".$res[' UID ']. "| Modified: Op_name ".$edit _info[' Op_name ']. "| Op_value ".$edit _info[' Op_value ']. "| Op_des: ".$edit _info[' Op_des ']. "| Start_time: ".$edit _info[' Start_time ']. "| End_time: ".$edit _info[' End_time ']. "| UID: ".$value;  -                 $type= "Modify"; -                 $obj= "User Configuration"; the                 $log _result=DD ("Logs.userop")->handle_logs ($user _info[' UserId '],$user _info[' Account '],$content,$type,$obj);  -             }Wuyi             Else the             {   -                $edit _info[' UID ']=$value;  Wu                $result=m (' User_set ')->add ($edit _info);  -                $content= "New User Configuration |id:".$result."| Op_name: ".$edit _info[' Op_name ']. "| Op_value: ".$edit _info[' Op_value ']. "| Op_des: ".$edit _info[' Op_des ']. "| Start_time: ".$edit _info[' Start_time ']. "| End_time: ".$edit _info[' End_time ']. "| UID: ".$edit _info[' UID ']. "| Is_del: ".$edit _info[' Is_del '];  About                $type= "New"; $                $obj= "User Configuration"; -                $log _result=DD ("Logs.userop")->handle_logs ($user _info[' UserId '],$user _info[' Account '],$content,$type,$obj);  -             } -         } A   +         if($result!==false&&$log _result ) the         {   -             $MD-commit (); $             return true; the         } the         Else the         {    the             $MD-rollback (); -             return false; in         } the    } the    Else About    { theE ("Parameter Error"); the    } the}

The use of Try catch in thinkphp

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.