Lock a MySQL table in PHP
If you do a select or insert query against the testTable while it is locked by the script below, the select or insert query will hanging there and execute only after this script released the lock
<?php ini_set('display_errors', 1); $con=mysqli_connect("127.0.0.1","root","","test"); mysqli_query($con,"LOCK TABLES testTable WRITE;"); //Do something or sleep for 30 seconds, no other users can access this table sleep(30); mysqli_query($con, "UNLOCK TABLES;"); mysqli_close($con); ?>
Search within Codexpedia
Custom Search
Search the entire web
Custom Search
Related Posts