Home > Backend Development > PHP Tutorial > Solve the problem of multiple people operating data tables at the same time under PHP_PHP tutorial

Solve the problem of multiple people operating data tables at the same time under PHP_PHP tutorial

WBOY
Release: 2016-07-13 17:19:13
Original
1029 people have browsed it

When multiple people insert or update the same table at the same time, the same piece of data often appears multiple times or some strange problems occur. This problem can be solved by queuing through the MySQL table lock mechanism.

Lock the table before inserting data in php
// lock talbe write
$sql = "LOCK TABLES alliance_perf WRITE";
mysql_query($sql, $this->mysql->conn);
unset($sql);
////////This is the data insert operation
// unlock table
$sql = "UNLOCK TABLES";
mysql_query($sql, $this->mysql->conn);
unset($sql);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532696.htmlTechArticleWhen multiple people insert or update the same table at the same time, the same piece of data will often appear. Many times or some strange problems can be solved through the lock table mechanism of mysql...
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