Can anyone test mysql table lock using 2 php scripts. And mysql_query().
I tried for a day but i couldn’t get table locked.
I want when one php script uses mysql table all other scripts wouldn’t have access to it.
Can you provide 2 simple tested php scripts. And if you can show how they work online it would be perfect.
But it should be so that when first script works and locks mysql table other scripts should wait for its turn.
Like a queue only one script can access myisam mysql table at the same time. But please test your script before answer because i tried many things many advises and nothing works.
I wouldn’t advise locking db tables explicitly if it is not aimed to manage complex db logic at transaction level. The queries will still be sent out, but fail due to the lock or worse other transactions become deadlocked because of a lock acquired at the wrong time.
As a consequence you are like to tank any semblance of performance in the application.
Edit:
http://dev.mysql.com/doc/refman/5.1/en/lock-tables.html
The documentation for mysql gives a detailed explanation of how the locks operate. Locks are acquired for the session using it, so if you want your session to not have access to certain tables and aliases, then you want to lock everything besides the tables you want to deny your session access to.
Not sure what locks you wish to test as an example.
Unlock is just