Topics

expRecord

expRecord is the basic Model class.  It is the parent model class for all modules in Exponent since it contains all the methods, properties, and helper functions needed to quickly get a module up and running.  Since expRecord is the generic 'model' it may be used by some modules to access generic data as the module controller would determine module specific parameters.

Though this is not intended as an API reference, we'll attempt to describe much of expRecord's work here.

In many ways, there is nothing needed in the module's model since it 1) inherits everything from expRecord and 2) makes assumptions about the model/data based on the controller/model name.  There can only be one model in the system with a given name and it must not duplicate any other class name in the system nor PHP.

The simplest usable model code would be the following saved in a module's 'models' folder as 'generic.php' and asssumes the data is stored in a table named 'generic'.

<?php
class generic extends expRecord {
}
?>

This provides enough information to get things up and running (provided we also create a genericController controller file).  Though we'll also need to create a 'generic' data definition in the 'definitions' folder if we intend to store static data (which is most often the case).  At this point, the generic model will be manipulated by the generic controller and would access the 'generic' database table.

From here on, we'd add to, override, or enhance expRecord methods to deviate from the standard expRecord behavior.

Loading Help