PHPmysql transaction problem instance analysis

Source: Internet
Author: User
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 ;}}

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.