filburt1
Fri 14th Jan '05, 1:24am
I want to lock one specific table from other threads (or PHP page loads, assuming they're related) from inserting data into it while my thread can still access it. This is the only table I care about; i.e., I don't want any others locked. When I'm done with the INSERTs in my thread, I want to unlock it for all other threads.
LOCK TABLES tablename WRITE doesn't seem to do what I want. When I call it and then query any other table in the same PHP page load, I get database errors like:
Invalid SQL: SELECT extension
FROM attachmenttype
WHERE enabled
mysql error: Table 'attachmenttype' was not locked with LOCK TABLES
What is the proper solution to this? The reason I'm doing it is because I'm making an assumption that a consecutive range of primary IDs exists starting at a certain ID, and if any other threads write to the table during that assumption, it will try to insert to an ID already taken (that I thought wasn't) and cause a collision.
If you know Java, I want to avoid the equivalent of a ConcurrentModificationException and synchronize the table so only my single script session can accces it.
LOCK TABLES tablename WRITE doesn't seem to do what I want. When I call it and then query any other table in the same PHP page load, I get database errors like:
Invalid SQL: SELECT extension
FROM attachmenttype
WHERE enabled
mysql error: Table 'attachmenttype' was not locked with LOCK TABLES
What is the proper solution to this? The reason I'm doing it is because I'm making an assumption that a consecutive range of primary IDs exists starting at a certain ID, and if any other threads write to the table during that assumption, it will try to insert to an ID already taken (that I thought wasn't) and cause a collision.
If you know Java, I want to avoid the equivalent of a ConcurrentModificationException and synchronize the table so only my single script session can accces it.