PHP 클래스 atk4\data\Persistence_SQL

상속: extends Persistence
파일 보기 프로젝트 열기: atk4/data 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$_default_class_addExpression string Default class when adding Expression field.
$_default_class_addField string Default class when adding new field.
$_default_class_hasMany string Default class when adding hasMany field.
$_default_class_hasOne string Default class when adding hasOne field.
$_default_class_join string Default class when adding join.
$connection atk4\dsql\Connection Connection object.

공개 메소드들

메소드 설명
__construct ( atk4\dsql\Connection | string $connection, string $user = null, string $password = null, array $args = [] ) Constructor.
_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.
action ( Model $m, string $type, array $args = [] ) : atk4\dsql\Query Executing $model->action('update') will call this method.
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, so if the code inside callback will fail, then all of the transaction will be also rolled back.
delete ( Model $m, mixed $id ) Deletes record from database.
dsql ( ) : atk4\dsql\Query Returns Query instance.
export ( Model $m, array | null $fields = null ) : array Export all DataSet.
expr ( Model $m, string $expr, array $args = [] ) : atk4\dsql\Expression Creates new Expression object from expression.
initField ( atk4\dsql\Query $q, Field $field ) Adds Field in Query.
initQuery ( Model $m ) : atk4\dsql\Query Initializes base query for model $m.
initQueryConditions ( Model $m, atk4\dsql\Query $q ) : atk4\dsql\Query Will apply conditions defined inside $m onto query $q.
initQueryFields ( Model $m, atk4\dsql\Query $q, array | null $fields = null ) Adds model fields in Query.
insert ( Model $m, array $data ) : mixed Inserts record in database and returns new record ID.
load ( Model $m, mixed $id ) : array Loads a record from model and returns a associative array.
loadAny ( Model $m ) : array Loads any one record.
prepareIterator ( Model $m ) : PDOStatement Prepare iterator.
tryLoad ( Model $m, mixed $id ) : array Tries to load data record, but will not fail if record can't be loaded.
tryLoadAny ( Model $m ) : array Tries to load any one record.
update ( Model $m, mixed $id, array $data ) Updates record in database.

보호된 메소드들

메소드 설명
initPersistence ( Model $m ) Initialize persistence.
setLimitOrder ( Model $m, atk4\dsql\Query $q ) Will set limit defined inside $m onto query $q.

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( atk4\dsql\Connection | string $connection, string $user = null, string $password = null, array $args = [] )
$connection atk4\dsql\Connection | string
$user string
$password string
$args array

_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

action() 공개 메소드

Executing $model->action('update') will call this method.
public action ( Model $m, string $type, array $args = [] ) : atk4\dsql\Query
$m Model
$type string
$args array
리턴 atk4\dsql\Query

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, so if the code inside callback will fail, then all of the transaction will be also rolled back.
public atomic ( callable $f ) : mixed
$f callable
리턴 mixed

delete() 공개 메소드

Deletes record from database.
public delete ( Model $m, mixed $id )
$m Model
$id mixed

dsql() 공개 메소드

Returns Query instance.
public dsql ( ) : atk4\dsql\Query
리턴 atk4\dsql\Query

export() 공개 메소드

Export all DataSet.
public export ( Model $m, array | null $fields = null ) : array
$m Model
$fields array | null
리턴 array

expr() 공개 메소드

Creates new Expression object from expression.
public expr ( Model $m, string $expr, array $args = [] ) : atk4\dsql\Expression
$m Model
$expr string
$args array
리턴 atk4\dsql\Expression

initField() 공개 메소드

Adds Field in Query.
public initField ( atk4\dsql\Query $q, Field $field )
$q atk4\dsql\Query
$field Field

initPersistence() 보호된 메소드

Initialize persistence.
protected initPersistence ( Model $m )
$m Model

initQuery() 공개 메소드

Initializes base query for model $m.
public initQuery ( Model $m ) : atk4\dsql\Query
$m Model
리턴 atk4\dsql\Query

initQueryConditions() 공개 메소드

Will apply conditions defined inside $m onto query $q.
public initQueryConditions ( Model $m, atk4\dsql\Query $q ) : atk4\dsql\Query
$m Model
$q atk4\dsql\Query
리턴 atk4\dsql\Query

initQueryFields() 공개 메소드

Adds model fields in Query.
public initQueryFields ( Model $m, atk4\dsql\Query $q, array | null $fields = null )
$m Model
$q atk4\dsql\Query
$fields array | null

insert() 공개 메소드

Inserts record in database and returns new record ID.
public insert ( Model $m, array $data ) : mixed
$m Model
$data array
리턴 mixed

load() 공개 메소드

Loads a record from model and returns a associative array.
public load ( Model $m, mixed $id ) : array
$m Model
$id mixed
리턴 array

loadAny() 공개 메소드

Loads any one record.
public loadAny ( Model $m ) : array
$m Model
리턴 array

prepareIterator() 공개 메소드

Prepare iterator.
public prepareIterator ( Model $m ) : PDOStatement
$m Model
리턴 PDOStatement

setLimitOrder() 보호된 메소드

Will set limit defined inside $m onto query $q.
protected setLimitOrder ( Model $m, atk4\dsql\Query $q )
$m Model
$q atk4\dsql\Query

tryLoad() 공개 메소드

Tries to load data record, but will not fail if record can't be loaded.
public tryLoad ( Model $m, mixed $id ) : array
$m Model
$id mixed
리턴 array

tryLoadAny() 공개 메소드

Tries to load any one record.
public tryLoadAny ( Model $m ) : array
$m Model
리턴 array

update() 공개 메소드

Updates record in database.
public update ( Model $m, mixed $id, array $data )
$m Model
$id mixed
$data array

프로퍼티 상세

$_default_class_addExpression 공개적으로 프로퍼티

Default class when adding Expression field.
public string $_default_class_addExpression
리턴 string

$_default_class_addField 공개적으로 프로퍼티

Default class when adding new field.
public string $_default_class_addField
리턴 string

$_default_class_hasMany 공개적으로 프로퍼티

Default class when adding hasMany field.
public string $_default_class_hasMany
리턴 string

$_default_class_hasOne 공개적으로 프로퍼티

Default class when adding hasOne field.
public string $_default_class_hasOne
리턴 string

$_default_class_join 공개적으로 프로퍼티

Default class when adding join.
public string $_default_class_join
리턴 string

$connection 공개적으로 프로퍼티

Connection object.
public Connection,atk4\dsql $connection
리턴 atk4\dsql\Connection