Home > Backend Development > PHP Tutorial > PHP mysql transaction problem example analysis, mysql example analysis_PHP tutorial

PHP mysql transaction problem example analysis, mysql example analysis_PHP tutorial

WBOY
Release: 2016-07-12 09:00:25
Original
820 people have browsed it

PHP mysql transaction problem example analysis, mysql example analysis

This article analyzes the PHP mysql transaction problem with an example. Share it with everyone for your reference, the details are as follows:

For myisam database, you can control the progress of 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: 数据库异常" );
mysql_query ( "SET NAMES 'utf8'" );
date_default_timezone_set ( 'Asia/Shanghai' );
/**
* 事务操作过程 BEGIN 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" . "更新记录成功";
    write_file ( $file, $data );
    return true;
  } else {
    print mysql_error ();
    mysql_query ( 'ROLLBACK' );
    mysql_query ( 'END' );
    $data .= "\r\n" . "更新记录失败(⊙o⊙)!!!";
    write_file ( $file, $data );
    return false;
  }
}

Copy after login

Readers who are interested in more content related to PHP operating MySQL can check out the special topic of this site: "Introduction Tutorial on PHP MySQL Database Operation"

I hope this article will be helpful to everyone in PHP programming.

Articles you may be interested in:

  • PHP Mysql’s method of implementing transfer function based on transaction processing
  • php Mysqli uses transaction processing to transfer money examples
  • PHP Two solutions to implement MySQL nested transactions in
  • php mysqli transaction control to implement bank transfer examples
  • Pdo mysql transaction usage examples under PDO
  • php to implement mysql transactions Processing method
  • PHP operates MySQL transaction instance
  • PHP uses Mysql transaction instance analysis
  • Execute MYSQL transaction in PHP to solve the problem of incomplete data writing
  • PHP mysql and mysqli transaction usage instructions sharing
  • Analysis of php mysql transaction rollback operation (with examples)
  • php mysql transaction rollback&commit example

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1093709.htmlTechArticlePHP mysql transaction problem example analysis, mysql example analysis This article analyzes the mysql transaction problem of PHP with an example. Share it with everyone for your reference, the details are as follows: For the myisam database, you can control...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template