7

I was pondering this today and trying to decide on the best route when it comes to storing data for an extension.

The data I am storing in an extension involves a many to many relationship with two entities.

When do you use the settings column in exp_extensions versus creating your own table where the data isn't serialized?

Let's say I have multiple instances, but with each single instance there will be the need to update data, delete, and relate to a member group id in the extension settings view.

One route I thought of is to unserialize the data, update the array, and then update the db? Yet with a table, you can utilize CI's active record functionality with data that is stored nicely. I'm confused on when to use one over the other. Help?

11

In this case, I think building your own settings table is the way to go for sure. Using the settings column should really only be for very minor yes/no types of settings, not storing actual data. Especially when you get into supporting MSM, where you need settings for each site, it can get hairy fast.

Plus, then your data is more easily searchable and readable, and you can be more selective about what you need to SELECT at any given time, etc, etc.

So yes: your own DB table.

|improve this answer|||||
  • Thanks Derek. Your answer gives confidence. I would upvote if I had the required reputation from this blasted site. – Bransin Feb 1 '13 at 7:27
  • If you need to store something as a serialized array, use JSON instead. – Brian Litzinger Feb 1 '13 at 14:18
  • @Bransin, while you cannot upvote, you will need to accept the answer, if it works best for you. – Yuri Salimovskiy Feb 1 '13 at 14:57
  • So using your own table as opposed to the settings column is basically for the advantage of developers? So they can have a better idea of what they're working on/with? – notacouch Feb 28 '13 at 1:06
  • 1
    @notacouch I suppose with all things to do with development best practices, it is about making things easier for developers, yes. Though in some cases that may mean more performant add-ons as well, which then is better for users. – Derek Hogue Feb 28 '13 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.