Database requests tend to be the slowest part of most applications. Therefore, it does not make sense to use databases to store frequently accessed information that is static in nature. For example, things like country codes and currency codes change very infrequently. Therefore, storing these within code objects makes sense but most frameworks don't offer a convenient way to maintain this static data if it is embedded within PHP code. GenHelm supports models that allow you to maintain data as if it were in a spreadsheet while, internally, the data becomes part of generated classes making the retrieval of the data extremely fast.
The php_array_data model allows you to maintain data much like a spreadsheet while the result of stowing the data is a PHP class that can be called to retrieve the data. As an example, consider the following specification showing the abbreviated province codes and tax rates for the Canadian province codes and territories.
Here we show one of the methods by which you could programmatically fetch a cell from this table.
require_once SITE_CLASS_PATH.'array_data/provinces.php';
$prov = new provinces();
$ontario_rate = $prov->get_value('Ontario','tax_rate');
Another common situation involves referencing information throughout the site that is subject to change. In such situations you would like to be able to define this information in one place and refer to it throughout the site. This way, if the information does change you can just update it centrally and the update with ripple throughout the site.
The globals model is used for this purpose. Here we show how globals are used to store phone numbers and address data.
Now that these globals have been defined, we can refer to these values from any other specification by using the $globals function as shown here in a bootgrid specification.
Other models that deal with data caching and retrieval include: