A database table model. More...
Public Member Functions | |
| __construct ($table_name=null) | |
| Constructor. | |
| set_fields () | |
| Gets information on fields in a table. | |
| set_relations () | |
| Gets information on relations between the selected table and others (one-to-many and many-to-one). | |
| get_field_properties ($db_model, $map_table) | |
| Get the field properties. | |
| get ($id=null) | |
| Get a record. | |
| first ($where=array(), $order_by=array()) | |
| Get the first record matching criteria. | |
| all ($where=array(), $order_by=array(), $limit=array()) | |
| Get an array of all records matching criteria. | |
| is_field ($field_name) | |
| Does the field exist? | |
| get_field ($field_name) | |
| Get a field. | |
| has_children () | |
| Is this model recursive? | |
| has_parent () | |
| Is this model recursive? | |
| get_parent_field_name () | |
| For recursive models, Get the field name which stores the parent ID. | |
| save (Db_Record &$record) | |
| Save a record. | |
| delete ($where=array()) | |
| Delete one or more records. | |
| set_default () | |
| Update the singleton record of the model to this one for future use. | |
| sql () | |
| Get the SQL data. | |
| root () | |
| For recursive models, get the root node of a tree. | |
Public Member Functions inherited from Base | |
| __call ($function, $params) | |
| The 'magic' call method will get/set for us invoked when the interpreter can not find a method the user is asking for. | |
| set_parameters ($arguments) | |
| Set variables from an array to member fields requires $this->optional_arguments or $this->required_arguments to have been set by the subclass. | |
Static Public Member Functions | |
| static | create ($table_name, $class_name='') |
| Factory method. | |
Public Attributes | |
| $h2o_safe = 1 | |
| can be used in h2o | |
Protected Member Functions | |
| get_save_values ($record) | |
| Get the values to save as an array. | |
Protected Attributes | |
| $table_name = '' | |
| Table name. | |
| $schema_name = '' | |
| Schema (database) name. | |
| $primary_key = '' | |
| Primary key field. | |
| $order_by = '' | |
| Default order. | |
| $db = '' | |
| Database object. | |
| $fields = array() | |
| Field names. | |
| $relations = array() | |
| Relations data. | |
| $record_class = "Db_Record" | |
| Record class name - this can be overridden to a custom class on a subclass. | |
| $field_class = "Db_Model_Field" | |
| Field class name - this can be overridden to a custom class on a subclass. | |
| $last_id = 0 | |
| The ID of the last record that was inserted. | |
Protected Attributes inherited from Base | |
| $optional_arguments = array() | |
| Array of options that can be set to variables. | |
| $required_arguments = array() | |
| Array of options that need to be set to variables. | |
A database table model.
| Db_Model::__construct | ( | $table_name = null | ) |
Constructor.
Creates a new instance, and adds it to the $_REQUEST array for future reference.
Reimplemented in Ui_model.
|
static |
Factory method.
Creates a new singleton instance of the class. If it has already been created, it uses the instance in the $_REQUEST array to save duplicate objects flying about.
| Db_Model::delete | ( | $where = array() | ) |
Delete one or more records.
| $where | the where conditions:
|
| Db_Model::get | ( | $id = null | ) |
Get a record.
If you supply an ID value, it will give you that record. If you don't, it will return a blank record for you to edit and save.
|
protected |
Get the values to save as an array.
Only the modified data is saved. NB If you make any changes here, consider Ui_Model implementation.
Reimplemented in Ui_model.
| Db_Model::set_fields | ( | ) |
Gets information on fields in a table.
Returns an array of properties for that field.
| Db_Model::set_relations | ( | ) |
Gets information on relations between the selected table and others (one-to-many and many-to-one).
Returns an array containing information on the relation.
1.8.1.1