PHP Класс atk4\data\Persistence

Наследование: use trait atk4\core\ContainerTrait, use trait atk4\core\FactoryTrait, use trait atk4\core\HookTrait, use trait atk4\core\AppScopeTrait, use trait atk4\core\NameTrait
Показать файл Открыть проект

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

Метод Описание
_add ( )
_serializeLoadField ( Field $f, mixed $value ) : mixed Override this to fine-tune un-serialization for your persistence.
_serializeSaveField ( Field $f, mixed $value ) : mixed Override this to fine-tune serialization for your persistence.
_typecastLoadField ( Field $f, mixed $value ) : mixed This is the actual field typecasting, which you can override in your persistence to implement necessary typecasting.
_typecastSaveField ( Field $f, mixed $value ) : mixed This is the actual field typecasting, which you can override in your persistence to implement necessary typecasting.
add ( Model | string $m, array $defaults = [] ) : Model Associate model with the data driver.
atomic ( callable $f ) : mixed Atomic executes operations within one begin/end transaction. Not all persistences will support atomic operations, so by default we just don't do anything.
connect ( string $dsn, string $user = null, string $password = null, array $args = [] ) : Persistence Connects database.
serializeLoadField ( Field $f, mixed $value ) : mixed Provided with a value, will perform field un-serialization.
serializeSaveField ( Field $f, mixed $value ) : mixed Provided with a value, will perform field serialization.
typecastLoadField ( Field $f, mixed $value ) : mixed Cast specific field value from the way how it's stored inside persistence to a PHP format.
typecastLoadRow ( Model $m, array $row ) : array Will convert one row of data from Persistence-specific types to PHP native types.
typecastSaveField ( Field $f, mixed $value ) : mixed Prepare value of a specific field by converting it to persistence-friendly format.
typecastSaveRow ( Model $m, array $row ) : array Will convert one row of data from native PHP types into persistence types. This will also take care of the "actual" field keys. Example:.

Защищенные методы

Метод Описание
initPersistence ( Model $m ) Extend this method to enhance model to work with your persistence. Here you can define additional methods or store additional data. This method is executed before model's init().

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

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

public _add ( )

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

Override this to fine-tune un-serialization for your persistence.
public _serializeLoadField ( Field $f, mixed $value ) : mixed
$f Field
$value mixed
Результат mixed

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

Override this to fine-tune serialization for your persistence.
public _serializeSaveField ( Field $f, mixed $value ) : mixed
$f Field
$value mixed
Результат mixed

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

This is the actual field typecasting, which you can override in your persistence to implement necessary typecasting.
public _typecastLoadField ( Field $f, mixed $value ) : mixed
$f Field
$value mixed
Результат mixed

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

This is the actual field typecasting, which you can override in your persistence to implement necessary typecasting.
public _typecastSaveField ( Field $f, mixed $value ) : mixed
$f Field
$value mixed
Результат mixed

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

Associate model with the data driver.
public add ( Model | string $m, array $defaults = [] ) : Model
$m Model | string Model which will use this persistence
$defaults array Properties
Результат Model

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

Atomic executes operations within one begin/end transaction. Not all persistences will support atomic operations, so by default we just don't do anything.
public atomic ( callable $f ) : mixed
$f callable
Результат mixed

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

Connects database.
public static connect ( string $dsn, string $user = null, string $password = null, array $args = [] ) : Persistence
$dsn string
$user string
$password string
$args array
Результат Persistence

initPersistence() защищенный Метод

Extend this method to enhance model to work with your persistence. Here you can define additional methods or store additional data. This method is executed before model's init().
protected initPersistence ( Model $m )
$m Model

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

Can be used for the purposes of encryption or storing unsupported formats.
public serializeLoadField ( Field $f, mixed $value ) : mixed
$f Field
$value mixed
Результат mixed

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

Can be used for the purposes of encryption or storing unsupported formats.
public serializeSaveField ( Field $f, mixed $value ) : mixed
$f Field
$value mixed
Результат mixed

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

Cast specific field value from the way how it's stored inside persistence to a PHP format.
public typecastLoadField ( Field $f, mixed $value ) : mixed
$f Field
$value mixed
Результат mixed

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

NOTE: Please DO NOT perform "actual" field mapping here, because data may be "aliased" from SQL persistences or mapped depending on persistence driver.
public typecastLoadRow ( Model $m, array $row ) : array
$m Model
$row array
Результат array

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

Prepare value of a specific field by converting it to persistence-friendly format.
public typecastSaveField ( Field $f, mixed $value ) : mixed
$f Field
$value mixed
Результат mixed

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

In: [ 'name'=>' John Smith', 'age'=>30, 'password'=>'abc', 'is_married'=>true, ] Out: [ 'first_name'=>'John Smith', 'age'=>30, 'is_married'=>1 ]
public typecastSaveRow ( Model $m, array $row ) : array
$m Model
$row array
Результат array