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
파일 보기 프로젝트 열기: atk4/data

공개 메소드들

메소드 설명
_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