PHPpdo transaction rollback code instance _ PHP Tutorial

Source: Internet
Author: User
PHPpdo transaction rollback code instance. PHPpdo transaction rollback code instance $ this-beginTransaction (); $ this-exec (updatepeoplesetage2); $ step1mysql tutorial _ error (); in your class, if an SQL error occurs, get PHP pdo transaction rollback code instance
$ This-> beginTransaction ();
$ This-> exec ('update people set age = 2 ');

// $ Step1 = mysql tutorial _ error (); // in your class, if an SQL error is executed, obtain the error code and function

$ This-> exec ('Insert INTO course (course, num) VALUES ("mathematics", 100 )');

// $ Step2 = mysql_error ();


If (! $ Step1 &&! $ Step2)
{
$ This-> commit ();
}
Else
{
$ This-> rollBack ();
}

Http://www.bkjia.com/PHPjc/630862.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/630862.htmlTechArticlePHP pdo transaction rollback code instance $ this-beginTransaction (); $ this-exec ('update people set age = 2 '); // $ step1 = mysql tutorial _ error (); // in your class, change it to get if an SQL execution error occurs...

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.