By mjlF95 on
I'm developing a module that I'd like for users to be able to keep individual settings for. I have an admin settings function that is working fine but is there a recommended method for letting individual users have their own settings? Should I just make a new table and store the settings there?
Comments
It certainly sounds to me
It certainly sounds to me like that's what you will have to do. No way you can store user specific settings in the variable table. With per-user data storage this is a clear case for a table to me. Just use the uid as a key and your good to go.
Thanks for confirmation on
Thanks for confirmation on that. Moving ahead with module specific user settings table.
Uid and persistent variables for per user configuration in D7
I'm not sure this follows the best practices but worked for me. It is possible to avoid an entire new data base table, appending user id to persistent variables.
This is much more inefficient
This is much more inefficient than creating your own tables. You are just cluttering up the variables table with user settings this way. Imagine if you get 10000 users - you will have 100000 rows in your variable table for each of those users. The entire variable table is cached, and the entire cache is loaded on each page load. In using this method, you could be loading the cache for thousands of users instead of the few hundred that the variables table usually has.
Conversely, using a separate table is what databases are made to do. In trying to be more efficient, you are actually making a significantly less efficient system.
Contact me to contract me for D7 -> D10/11 migrations.