Home >Backend Development >PHP Tutorial >apache php mysql php lock table operation
header('content-type:text/html;charset=utf8');
$Database = new PDO('mysql:host=127.0.0.1;dbname=iweb','user', 'Password');
//Execute the SQL statement to lock the userinfo table
$sql = "LOCK TABLES iwebshop_goods WRITE";
//The WRITE lock of the table blocks all other mysql query processes
$Database-> exec($sql);
//Perform update or write operation
$sql = "UPDATE iwebshop_goods SET `store_nums`=`store_nums`-1 WHERE store_nums>0 and id=1";
$Database-> ;exec($sql);
//After all write operations of the current request are completed, execute the unlock sql statement
$sql = "UNLOCK TABLES";
$Database->exec($sql);
The above introduces the lock table operation of apache php mysql php, including the content of apache php mysql. I hope it will be helpful to friends who are interested in PHP tutorials.