I am using zencart style countries table in my project such as for countries in address book etc. When refer the country, I used the coutries_id such as in my address book programming.
Here is the question, when I dealing with the special cases such as if the countries is usa or canada, due to in the whole site programming, I refer the country by its id, such as in the countries drop down menu, the id is the value of every option of the countries drop down menu.
So I detect if a country is usa by to see if its id is 223, if a country is canada by to see if its id is 38.
If this involve to detect many other countries, then I will get the id and then do a sql search get the ISO code for that id when i need to know which country is which.
But many of my projects will be to just to see if the country is USA or Canada (id as 223 or 38), or Not usa or canda.
I can keep using the same countries table, maybe add some new countries or change some countries' names. But usa will still be id 233 and canada is still 38.
In this situation:
1) should I hard code in this 223 and 38 for easy and quick detect if it is usa or canada?
or
2) should I call the sql every time to get the iso code from id and then detect to see if it is usa or canada?
or
3) create the global value for usa and canada countries id from the database and use this global value over the site?
In theory, the option 3) is better than 2) is better than 1).
But in practice, what is your approach?
I had been selecting the options preferred by theory before, but sometime, I think selecting the options by practice will be better. Like I had designed my own systems like the zencart style, design for multi-langauges usage, and if it is one langauge, then just not use the multilangauge feature. This is preferred by theory because its flexiblity. But in practice, large pecent of my projects are one language only. In practice, if I design for 1 language, it will be easy to use, fast, stable, and easy to update. For the flexibility of multi-langauges issues, I can chose only take the 1 language projects. Or I can deal with multi-langauge cases (modify from the most current 1 langauge version etc.) case by case.
thanks