Agile Toolkit
4.2
Agile Toolkit is a powerful web development framework. Inspired by GUI Applications development
|
Public Member Functions | |
init () | |
__clone () | |
addField ($name) | |
set ($name, $value=undefined) | |
get ($name=null) | |
setDirty ($name) | |
loaded () | |
unload () | |
reset () | |
setSource ($controller, $table=null, $id=null) | |
{{{ Operation with external Data Controllers | |
load ($id=null) | |
save ($id=null) | |
delete ($id=null) | |
offsetExists ($name) | |
}}} | |
offsetGet ($name) | |
offsetSet ($name, $val) | |
offsetUnset ($name) | |
rewind () | |
next () | |
current () | |
key () | |
valid () | |
newField ($name) | |
hasField ($name) | |
getEntityCode () | |
getField ($f) | |
Data Fields | |
$default_exception = 'Exception' | |
$field_class = 'Field' | |
$strict_fields = false | |
$table | |
$id = null | |
$data = array() | |
$dirty = array() |
Implementation of a Generic Model. Model has fields which you add with addField() and access through get() and set() You can also load and save model through different storage controllers. This model is designed to work with linear, non-SQL resources, if you are looking to have support for joins, ordering, advanced SQL syntax, look into Model_Table It's recommended that you create your own model class based on generic model where you define fields, but you may also use instance of generic model. Use: class Model_PageCache extends Model { function init(){ parent::init(); $this->addField('content')->allowHtml(true); } function generateContent(){ //complex computation // ... $this->set('content',$content); } } $pc=$this->add('Model_PageCache')->setSource('Memcached'); $pc->load($this->api->page); if(!$pc->loaded()){ $pc->set('page',$this->api->page'); $pc->generateContent(); $pc->save(); } See http://agiletoolkit.org/about/license
__clone | ( | ) |
Reimplemented from AbstractObject.
Reimplemented in Model_Table.
addField | ( | $ | name | ) |
Creates field definition object containing field meta-information such as caption, type validation rules, default value etc
current | ( | ) |
Reimplemented in Model_Table.
delete | ( | $ | id = null | ) |
Deletes record associated with specified $id. If not specified, currently loaded record is deleted (and unloaded)
Reimplemented in Model_Table.
get | ( | $ | name = null | ) |
Return value of the field. If unspecified will return array of all fields.
getEntityCode | ( | ) |
getField | ( | $ | f | ) |
hasField | ( | $ | name | ) |
init | ( | ) |
Initialize object. Always call parent
This method is called for initialization
Reimplemented from AbstractObject.
Reimplemented in Model_Table.
key | ( | ) |
Reimplemented in Model_Table.
load | ( | $ | id = null | ) |
Attempt to load record with specified ID. If this fails, no error is produced
Reimplemented in Model_Table.
loaded | ( | ) |
Returns if the records has been loaded successfully
newField | ( | $ | name | ) |
next | ( | ) |
Reimplemented in Model_Table.
offsetExists | ( | $ | name | ) |
}}}
offsetGet | ( | $ | name | ) |
offsetSet | ( | $ | name, |
$ | val | ||
) |
offsetUnset | ( | $ | name | ) |
reset | ( | ) |
rewind | ( | ) |
Reimplemented in Model_Table.
save | ( | $ | id = null | ) |
Saves record with current controller. If no argument is specified, uses $this->id. Specifying "false" will create record with new ID. Returns ID of saved record
Set value of the field. If $this->strict_fields, will throw exception for non-existant fields. Can also accept array
setDirty | ( | $ | name | ) |
When fields are changed, they are marked dirty. Only dirty fields are saved when save() is called
setSource | ( | $ | controller, |
$ | table = null , |
||
$ | id = null |
||
) |
{{{ Operation with external Data Controllers
Associates appropriate controller and loads data such as 'Array' for Controller_Data_Array class
unload | ( | ) |
Forget loaded data
Reimplemented in Model_Table.
valid | ( | ) |
Reimplemented in Model_Table.
$data = array() |
$default_exception = 'Exception' |
Exception class to use when $this->exception() is called
Reimplemented from AbstractObject.
$dirty = array() |
$field_class = 'Field' |
The class prefix used by addField
$strict_fields = false |
If true, model will now allow to set values for non-existant fields
$table |
Contains information about table/file/bucket/array used by Controller to determine source