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...