EnumAdapter
extends BaseAdapter
in package
This adapter is in charge of ensuring that only values that are inside the range defined by the field are stored. If the user tries to set data that is not valid the adapter will throw an exception.
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.
- $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).
- $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() : mixed
- Returns the data as it should be stored by the DBMS. Please note that most DBMS don't accept any complex types like Arrays and Objects directly, this method allows to prepare the data accordingly before storing it.
- dbSetData() : mixed
- When the database defines the data it is important that it also overrides the src element, setting this element as in sync again. This is important as otherwise the element will find data that is not in sync even though it was.
- 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
- Verifies the data this method receives is inside the defined values by the field.
- validate() : ValidationResult
- Returns whether the data is valid or not. This data is stored inside a ValidationResult class allowing further checks.
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
$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()
Returns the data as it should be stored by the DBMS. Please note that most DBMS don't accept any complex types like Arrays and Objects directly, this method allows to prepare the data accordingly before storing it.
public
dbGetData() : mixed
Return values
mixed —dbSetData()
When the database defines the data it is important that it also overrides the src element, setting this element as in sync again. This is important as otherwise the element will find data that is not in sync even though it was.
public
dbSetData(mixed $data) : mixed
Parameters
- $data : mixed
Return values
mixed —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()
Verifies the data this method receives is inside the defined values by the field.
public
usrSetData(string $data) : mixed
Parameters
- $data : string
Tags
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