CodeIgniter Forums

Full Version: Drop down menus and lookup tables?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]jleequeen[/eluser]
I'm trying to decide whether to hard code some drop down menus or use lookup tables. I'm the kind of person that would much rather use real data in fields as opposed to a generic id that relates to another table where they make sense. For instance, if I need a drop down list of counties in my state, and these will never change, then I'd rather see the county name in a county field within a table, than a county_id...that doesn't really mean anything. I realize you sacrifice a little speed by using the text, but it's worth it to me because the complexity of joins is removed. Also, there are the little dropdown list that you only need say 5 values. Obviously you don't need a lookup table in you db to represent this small dropdown.

What I am trying to decide is if I implement this hardcoding of certain drop down menus, what is the best approach in CI. Obviously I don't want to duplicate hardcoding of a data array every time in a controller to pass to the form_dropdown helper. Is there a best place to put predefined array lists to use globally throughout your application?

El Forum

[eluser]mdowns[/eluser]
Why not use a model that returns a hard-coded array?

El Forum

[eluser]jleequeen[/eluser]
You know, after posting, I was thinking along similar lines. It logically seems that's where it should be. You've just reaffirmed it for me. Thanks for taking the time to reply!