I have the following Codeigniter (MySQL related) error in my application
Error Number: 1100
Table 'users' was not locked with LOCK TABLES
SELECT * FROM (`users`) WHERE `ID` = '1'
How can I fix this problem – I tried UNLOCK TABLES but this doesn’t fix the problem, any ideas?
This means you did this query inside a transaction or after a LOCK TABLES (you didn’t write the code, so I’m assuming you used a LOCK TABLES before).
When you’re in a transaction, you need to get locks on ALL tables you’re using in FROM statements, not only the ones you are inserting/updating.
You need to add a ‘users READ’ to your LOCK TABLES statement. It tells concurrent queries that it is fine to read from ‘users’ table, but not to write, since you’re counting on those values being up-to-date.
This manual page pretty much explains this error:
http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html