This article mainly introduces the PHPmysql transaction problem, and analyzes the related skills of MySQL myisam database in PHP operations in the form of examples, for more information about mysql transactions in PHP, see the examples in this article. We will share this with you for your reference. The details are as follows:
For myisam databases, you can control transactions:
$ Mysqlrl = mysql_connect ($ db_config ["host"], $ db_config ["user"], $ db_config ["pass"], true); if (! $ Mysqlrl) {$ msg = mysql_error (); die ('could not connect :'. $ msg);} mysql_select_db ($ db_config ["data"], $ mysqlrl) or die ("error: database exception"); mysql_query ("set names 'utf8 '"); date_default_timezone_set ('Asia/Shanghai');/*** BEGIN in commit end */mysql_query ('begin'); $ flag3 = mysql_query ($ sql3 ); $ flag1 = mysql_query ($ sql1); $ flag2 = mysql_query ($ sql2); if ($ flag1 & $ flag1 & $ Flag3) {mysql_query ('commit '); mysql_query ('end'); $ data. = "\ r \ n ". "Update record succeeded"; write_file ($ file, $ data); return true;} else {print mysql_error (); mysql_query ('rollback'); mysql_query ('end '); $ data. = "\ r \ n ". "An error occurred while updating the record (⊙ o ⊙ )!!! "; Write_file ($ file, $ data); return false ;}}