When multiple users operate data tables in php at the same time and perform insert or update operations on the same table, the same data may occur many times or some strange problems, the mysql lock table mechanism can be used for queuing to solve this problem. before inserting data in php, the lock table // locktalbewrite & nbsp; & nbsp solves the problem of simultaneous data table operation by multiple users in php.
When multiple people insert or update the same table at the same time, the same data may occur many times or some strange problems, the mysql lock table mechanism can be used for queuing to solve this problem.
Lock table before inserting data in php
// Lock talbe write
$ SQL = "LOCK TABLES alliance_perf WRITE ";
Mysql_query ($ SQL, $ this-> mysql-> conn );
Unset ($ SQL );
/////// Here is the data insert operation
// Unlock table
$ SQL = "UNLOCK TABLES ";
Mysql_query ($ SQL, $ this-> mysql-> conn );
Unset ($ SQL );