Documentation

ReferenceAdapter extends BaseAdapter
in package

The reference adapter allows models to provide models for objects that are just referenced. This prevents the user from having to resolve IDs manually.

This adapter will return the appropriate model for the given table.

Tags
author

César de la Cal Bretschneider cesar@magic3w.com

Table of Contents

$data  : mixed
The current data stored in this adapter. The data can be validated before being sent to the DBMS and parsed before being used in this system. This is the data the system usually handles as there is no use for the data that was originally placed inside the DB.
$field  : Field
This is the logical field the adapter contains data for. Allowing the system to check the type of the field and several other tasks that are necessary.
$local  : Model|array<string|int, mixed>
$model  : Model
This is the model this field belongs to. This makes it possible for this object to act accordingly to a certain content (for example, you want to deliver data about a relationship between two elements).
$remote  : Model|array<string|int, mixed>
Represents the data that the DBMS holds. This may be Model, Query or null.
$src  : mixed
This property holds the data as it has been fetched from the database. This can cause issues when holding very highly concurrent data as the data could have been modified on the database and stored already. Rolling back does not verify the data on the DBMS hasn't changed.
__construct()  : mixed
Creates a new Adapter. The adapter creates a bridge between a field, a model and the data it contains, the model can use this to create a consistent data relation between the DB and the programmer's scope.
commit()  : mixed
Sets the data as stored to the database and therefore as synced. After committing, rolling back will return the current value.
dbGetData()  : type
This method allows the DBMS to fetch data to be written to the database.
dbSetData()  : void
Receives data from the DBMS. This endpoint allows the DBMS to set data to the adapter. This means that the data will be an array containing the data pertaining to the logical field (this may be more than one column)
getField()  : Field
Returns the field (database column) the adapter is holding data for. This allows the driver to test for the field or getting it's name when needed.
getModel()  : Model
Returns the Model containing this adapter. Allowing to have objects which do not have a reference to the model it belongs to to read the data.
isSynced()  : bool
Returns the current synchronization status with the database. If the data is the same inside the database and the program scope this function will return true. Otherwise it'll return false.
rollback()  : mixed
Resets the data to the status the database holds. This is especially interesting if you want to undo certain changes.
usrGetData()  : mixed
Returns the data for the user scope. This may contain special objects and arrays as opposed to the methods planned for the DBMS.
usrSetData()  : mixed
Returns the data that is meant to reach the 'user space'. Objects here should be programmer friendly and can be objects if needed.
validate()  : ValidationResult
Returns whether the data is valid or not. This data is stored inside a ValidationResult class allowing further checks.
resolve()  : mixed

Properties

$data

The current data stored in this adapter. The data can be validated before being sent to the DBMS and parsed before being used in this system. This is the data the system usually handles as there is no use for the data that was originally placed inside the DB.

private mixed $data

$field

This is the logical field the adapter contains data for. Allowing the system to check the type of the field and several other tasks that are necessary.

private Field $field

$model

This is the model this field belongs to. This makes it possible for this object to act accordingly to a certain content (for example, you want to deliver data about a relationship between two elements).

private Model $model

$remote

Represents the data that the DBMS holds. This may be Model, Query or null.

private Model|array<string|int, mixed> $remote

$src

This property holds the data as it has been fetched from the database. This can cause issues when holding very highly concurrent data as the data could have been modified on the database and stored already. Rolling back does not verify the data on the DBMS hasn't changed.

private mixed $src

Methods

__construct()

Creates a new Adapter. The adapter creates a bridge between a field, a model and the data it contains, the model can use this to create a consistent data relation between the DB and the programmer's scope.

public __construct(Field $field, Model $model) : mixed
Parameters
$field : Field
$model : Model
Return values
mixed

commit()

Sets the data as stored to the database and therefore as synced. After committing, rolling back will return the current value.

public commit() : mixed
Return values
mixed

dbGetData()

This method allows the DBMS to fetch data to be written to the database.

public dbGetData() : type
Tags
throws
PrivateException
Return values
type

dbSetData()

Receives data from the DBMS. This endpoint allows the DBMS to set data to the adapter. This means that the data will be an array containing the data pertaining to the logical field (this may be more than one column)

public dbSetData(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>
Return values
void

getField()

Returns the field (database column) the adapter is holding data for. This allows the driver to test for the field or getting it's name when needed.

public getField() : Field
Return values
Field

getModel()

Returns the Model containing this adapter. Allowing to have objects which do not have a reference to the model it belongs to to read the data.

public getModel() : Model
Return values
Model

isSynced()

Returns the current synchronization status with the database. If the data is the same inside the database and the program scope this function will return true. Otherwise it'll return false.

public isSynced() : bool
Return values
bool

rollback()

Resets the data to the status the database holds. This is especially interesting if you want to undo certain changes.

public rollback() : mixed
Return values
mixed

usrGetData()

Returns the data for the user scope. This may contain special objects and arrays as opposed to the methods planned for the DBMS.

public usrGetData() : mixed
Return values
mixed

usrSetData()

Returns the data that is meant to reach the 'user space'. Objects here should be programmer friendly and can be objects if needed.

public usrSetData(mixed $data) : mixed

You should avoid making verifications / parsing the data in this function, stuff you think should go here probably belongs in dbSetData()

Parameters
$data : mixed

Data to be contained in the database.

Return values
mixed

Data to be delivered to the programmer

validate()

Returns whether the data is valid or not. This data is stored inside a ValidationResult class allowing further checks.

public validate() : ValidationResult
Return values
ValidationResult

Search results