Inherited by Model.
Public Member Functions | |
| Model_Base () | |
| depend ($model) | |
| & | import_plugin ($name) |
| validate_for_insert ($data) | |
| validate_for_update ($data) | |
| validate ($data, $is_update=false) | |
| purify ($data) | |
| sanitize ($data) | |
| create () | |
| get ($id) | |
| invalidate ($id) | |
| get_record ($id) | |
| get_bare ($id) | |
| get_multi ($ids, $ignore_empty=true) | |
| get_value ($id, $column) | |
| get_by ($column, $value) | |
| get_all_by ($column, $value) | |
| get_all () | |
| get_or_404 ($id) | |
| delete ($id) | |
| insert ($data) | |
| update ($data) | |
| list_params () | |
| __call ($name, $args) | |
| save ($data) | |
| load ($id) | |
| create_record () | |
| enum_schema () | |
Public Attributes | |
| $db = null | |
| $web = null | |
| $cache = null | |
| $depends = null | |
| $plugins = null | |
| $context = null | |
| $table = null | |
| $pk = 'id' | |
| $default_sort = 'id' | |
| $per_page = 50 | |
| $enable_cache = false | |
| $files = null | |
PRONTO WEB FRAMEWORK Copyright (C) 2006, Judd Vinet
Description: Base class for all data models. Many of the methods here will be overridden by subclasses.
NOTE: This class is now deprecated in favor of the newer RecordModel and RecordSelector classes. Please use those instead.
Definition at line 15 of file model.php.
| Model_Base::__call | ( | $ | name, | |
| $ | args | |||
| ) |
TODO: PHP5 only!
Call like so: $this->set_mycolname($id, $value) and: $this->get_mycolname($id)
Definition at line 463 of file model.php.
References $args, and invalidate().
| Model_Base::create | ( | ) |
Return a new/fresh entity. This method is responsible for returning a brand new, un-edited record that will be used to prepopulate form fields in a "Create" form for this data entity.
Definition at line 234 of file model.php.
Referenced by create_record().
| Model_Base::delete | ( | $ | id | ) |
Delete a single entity by PK
| int | $id |
Definition at line 407 of file model.php.
References invalidate().
| Model_Base::depend | ( | $ | model | ) |
Load another model as a dependency of this one.
| string | $model_name |
Definition at line 130 of file model.php.
References Factory::model().
| Model_Base::enum_schema | ( | ) |
Definition at line 503 of file model.php.
References list_params().
| Model_Base::get | ( | $ | id | ) |
Return a single record by PK. Normally, you won't want to override this method. Instead, override the get_record() method, which does the actual fetching/assembling of a data record for use by other objects.
| int | $id |
Definition at line 247 of file model.php.
References get_record().
Referenced by import_plugin(), and Model_Base().
| Model_Base::get_all | ( | ) |
| Model_Base::get_all_by | ( | $ | column, | |
| $ | value | |||
| ) |
Fetch all rows by a specified column. If $column and $value are arrays, then "AND" all the values in the WHERE clause.
| mixed | $column | |
| mixed | $value |
Definition at line 363 of file model.php.
References get_multi().
| Model_Base::get_bare | ( | $ | id | ) |
Return a single bare record by PK. Returns a single row from the table, no other data manipulation is performed. Normally the Model::get_record() method is overridden to do additional data work, so this method serves to retain a plain record-getter.
| int | $id |
Definition at line 300 of file model.php.
Referenced by get_record().
| Model_Base::get_by | ( | $ | column, | |
| $ | value | |||
| ) |
| Model_Base::get_multi | ( | $ | ids, | |
| $ | ignore_empty = true | |||
| ) |
Return multiple records by PK, optionally ignoring empty/false records.
| array | $ids | |
| boolean | $ignore_empty Ignore empty records. |
Definition at line 312 of file model.php.
Referenced by get_all(), and get_all_by().
| Model_Base::get_or_404 | ( | $ | id | ) |
| Model_Base::get_record | ( | $ | id | ) |
Return a full record for this entity, looked up by PK. Normally you will want to override this method to do any additional work on the record before returning it to the caller.
| int | $id |
Definition at line 286 of file model.php.
References get_bare().
Referenced by get().
| Model_Base::get_value | ( | $ | id, | |
| $ | column | |||
| ) |
| & Model_Base::import_plugin | ( | $ | name | ) |
Import a plugin (aka "page plugin").
| string | $name Plugin name |
Definition at line 142 of file model.php.
References get(), and Factory::plugin().
| Model_Base::insert | ( | $ | data | ) |
Insert a new entity into the table
| array | $data |
Definition at line 419 of file model.php.
References sanitize().
Referenced by save().
| Model_Base::invalidate | ( | $ | id | ) |
| Model_Base::list_params | ( | ) |
Return some data used for generating smart SQL for lists/grids.
Definition at line 442 of file model.php.
Referenced by enum_schema().
| Model_Base::Model_Base | ( | ) |
Constructor for all models
Definition at line 104 of file model.php.
References get().
Referenced by Model::Model().
| Model_Base::purify | ( | $ | data | ) |
Use the HTML checker to remove any possible XSS attacks (eg, <script> tags)
| array | $data |
Definition at line 199 of file model.php.
References DS.
Referenced by sanitize().
| Model_Base::sanitize | ( | $ | data | ) |
| Model_Base::save | ( | $ | data | ) |
BACKWARDS COMPATIBILITY
This makes the basic model functions compatible with the newer RecordModel class.
| Model_Base::update | ( | $ | data | ) |
Update an entity
| array | $data |
Definition at line 430 of file model.php.
References invalidate(), and sanitize().
Referenced by save().
| Model_Base::validate | ( | $ | data, | |
| $ | is_update = false | |||
| ) |
Perform the correct validation routine depending on insert/update mode.
| array | $data | |
| bool | $is_update Whether this data manipulation is an UPDATE or not |
Definition at line 185 of file model.php.
References validate_for_insert(), and validate_for_update().
| Model_Base::validate_for_insert | ( | $ | data | ) |
Validate data for an INSERT. To be overridden by subclasses.
| array | $data |
Definition at line 162 of file model.php.
Referenced by validate().
| Model_Base::validate_for_update | ( | $ | data | ) |
Validate data for an UPDATE. To be overridden by subclasses.
| array | $data |
Definition at line 173 of file model.php.
Referenced by validate().
| Model_Base::$context = null |
This can be set by the page controller acting on the model. It defines the context with which a record is being modified. For example, a Page_CRUD controller may set the model's context to 'ADMIN', indicating that an authorized administrator is modifying a record from a backend admin console, and so regular validation should be bypassed.
The model can then act on this setting in its overridden methods (such as validate, insert, update, etc.)
This setting is optional.
| Model_Base::$enable_cache = false |
Enable caching for this entity. Only enable this if you plan to be diligent about _only_ inserting/updating/fetching/deleting this entity _through_ the model interface. If you interact with the data yourself (eg, through $this->db in a controller) then you will undermine the caching layer.
| Model_Base::$files = null |
An array of files associated with this model, used by Page_CRUD to handle file uploads. The 'type' element determines the acceptable MIME type(s). Use an array for multiple types, or "image" to accept normal image types. Omit it to accept any file.
If type==image, then images will be converted to JPEG for consistency. If type==image, then use 'max_width' and 'max_height' to optionally resize images, maintaining aspect ratio.
The filename parameter can include any values from the record returned from the model's get() method. Each data key should be surrounded in angle brackets (eg, "<name>").
Array keys in $files must match those of the create/edit form defined in the template.
Example:
var $files = array( 'image' => array( 'type' => 'image', 'max_width' => '640', // used for type==image only 'max_height' => '800', // used for type==image only 'webroot' => DIR_WS_DATA_IMG, 'fileroot' => DIR_FS_DATA_IMG, 'filename' => "<id>.jpg" ) );
| Model_Base::$per_page = 50 |
| Model_Base::$pk = 'id' |
| Model_Base::$table = null |
1.6.1