I've noticed that some modules seem to abstract the names of the DB tables by using brackets, for example in user.module:
SELECT * FROM {users} ....
or
SELECT r.rid, r.name FROM {role} ....
How do these get translated into the actual table names? When setting up new tables for my own modules, how can I do the same?
Instead of: SELECT * from mymoduletable ...
Use: SELECT * from {mymoduletable} where it may or may not have a table prefix.
The basic problem here is that I used a table prefix in production, but not offline, partially due to the sharing of an existing database in production while having full control of the offline copy. I don't want to change my code when uploading it to prod.
Thanks!
Comments
The key is to always use the brackets
In both your install code and module, that way the table prefix setting is handled correctly in both cases. The brackets by the way are handled with in db function calls (like db_query(