PHP Класс Controller_Data, atk4

Наследование: extends Controller_Base
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$auto_track_element When controller is added into model, the model will automatically keep track of it and will not dispose of it.
$default_exception
$supportConditions Conditions can be set on non-primary field. This capability of data controller allows your model to use methods such as addCondition, loadBy, tryLoadBy etc. Each of those methods can be supplied with two arguments - the field and value and exact matching will be used. For three-argument use, see property $supportOperators.
$supportLimit Limit makes it possible to specify count / skip for the model, which is necessary for pagination.
$supportOperators Controller is required to support '>', '<', '=', '!=', '<=', '>=' operators even if database uses diffirent notation, due to consistency. If database supports additional operators, you can list them as an array in this attribute, e.g.: ['like','is','is not']. You may also set $supportOperators='all' which will indicate that this controller supports all possible operators, although this is not advised.
$supportOrder Controller allows re-ordering data set by non-primary field in either ascending or descending order. Models support ordering on multiple fields. If controller does not support multiple ordering fields, then the last field to be used for ordering must take precedence.
$supportRef This would be supported by most data controllers.

Открытые методы

Метод Описание
d ( $model )
delete ( $model, $id ) Locate and remove record in the storade with specified $id. Return true if record was deleted or false if it wasn't found. In most cases, the record data will first be loaded and then deleted, just to make sure the record is accessible with specified conditions, so you can silently ignore error.
loadById ( $model, $id ) Locate and load data for a specified record. If data backend supports selective loading of fields, you may call model->getActualFields to get a list of required fields for a model. When non-array is returned, you should load all fields.
loadCurrent ( $model, &$cursor ) Load next data row from cursor.
prefetchAll ( $model ) Create a new cursor and load model with the first entry. Returns cursor, which will then be passed to loadCurrent() for loading more results.
save ( $model, $id, $data ) Writes record containing $data into the data store under id=$id.
setSource ( $model, $data ) Associates model with the collection/table in this data store identified by second argument. For instance for Controller_Data_SQL the second argument would be a table.

Описание методов

d() публичный Метод

public d ( $model )

delete() абстрактный публичный Метод

Locate and remove record in the storade with specified $id. Return true if record was deleted or false if it wasn't found. In most cases, the record data will first be loaded and then deleted, just to make sure the record is accessible with specified conditions, so you can silently ignore error.
abstract public delete ( $model, $id )

loadById() абстрактный публичный Метод

Locate and load data for a specified record. If data backend supports selective loading of fields, you may call model->getActualFields to get a list of required fields for a model. When non-array is returned, you should load all fields.
abstract public loadById ( $model, $id )

loadCurrent() публичный Метод

Load next data row from cursor.
public loadCurrent ( $model, &$cursor )

prefetchAll() абстрактный публичный Метод

If the data store does not support cursors, then fetch all data and return array. loadCurrent will automatically array_shift one record on each call.
abstract public prefetchAll ( $model )

save() абстрактный публичный Метод

If the ID field can vary, consult $model->id_field. You do not have to worry about default fileds, because their values will automatically be in $data. If $id is null then new record must be created. If $id is specified, then record must be overwritten. Method must return $id of stored record. This method may throw exceptions.
abstract public save ( $model, $id, $data )

setSource() публичный Метод

All necessary data must be stored in $model->_table[$this->short_name] to avoid conflicts between different controllers and to allow user to use one controller with multiple models.
public setSource ( $model, $data )

Описание свойств

$auto_track_element публичное свойство

When controller is added into model, the model will automatically keep track of it and will not dispose of it.
public $auto_track_element

$default_exception публичное свойство

public $default_exception

$supportConditions публичное свойство

Conditions can be set on non-primary field. This capability of data controller allows your model to use methods such as addCondition, loadBy, tryLoadBy etc. Each of those methods can be supplied with two arguments - the field and value and exact matching will be used. For three-argument use, see property $supportOperators.
public $supportConditions

$supportLimit публичное свойство

Limit makes it possible to specify count / skip for the model, which is necessary for pagination.
public $supportLimit

$supportOperators публичное свойство

Controller is required to support '>', '<', '=', '!=', '<=', '>=' operators even if database uses diffirent notation, due to consistency. If database supports additional operators, you can list them as an array in this attribute, e.g.: ['like','is','is not']. You may also set $supportOperators='all' which will indicate that this controller supports all possible operators, although this is not advised.
public $supportOperators

$supportOrder публичное свойство

Controller allows re-ordering data set by non-primary field in either ascending or descending order. Models support ordering on multiple fields. If controller does not support multiple ordering fields, then the last field to be used for ordering must take precedence.
public $supportOrder

$supportRef публичное свойство

This would be supported by most data controllers.
public $supportRef