I created a file in php and under this i wrote a code to lock a table with read mode. Below that file i wrote a insert operation into the same table, but as we know that read lock only supports read operation, meaning you can only view what is in the table, but you can't modify it. and it is running fine.

PROBLEM_EXIST_HERE: I created another file which contains the same insert operation into the same table. Here i'm only writing the insert operation, not the locking code.

Before using this file i used (RUN) the first file (which contains Locking+insert) operation and after that i opened the new tab in the same browser and run second file (containing only insert op.).

Now as we know that read lock is already fixed on the table, then why is the insert operation going on? Why won't it show me an error stating that the table is in READ locked mode and thus cannot be updated? Does anybody have any idea how to solve this problem?

And does anybody know how to know to see whether a table is locked in read or write condition in mysql db? Can anybody can tell me the php code for this? I have searched through the day and comes with no solution. Please write simple solution in simple language.

Member Avatar for diafol

http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html

States:

"A session can acquire or release locks only for itself. One session cannot acquire locks for another session or release locks held by another session."

PLease show your code and any relevant php.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.