Documentation

AdapterInterface

An adapter is basically a simple block that contains receives and delivers data both to the user and the database. This turns it into a great tool to sanitize user data and prepare information from the DB in a way that it's user friendly.

The adapter can also set and receive virtual data, allowing it to hold information that is not present / stored to the database. I.e. This is useful for arrays, which are not contained as that in the database.

An array can either be stored in a serialized manner (which would require the adapter to serialize / unserialize it every time) or as a child field, in which case you can store several records that 'belong' to the parent record but are stored in different tables.

Table of Contents

commit()  : mixed
Settles the content inside the adapter. This method is usually called when the model is being stored. This means the data is considered final and the data inside the adapter is no longer out of sync with the database.
dbGetData()  : mixed
This method returns the data the adapter wants to store to the database. The DBMS controller should use this endpoint to collect the data it will store to the driver.
dbSetData()  : mixed
This receives data from the database and stores it into the adapter. The reason there are two methods for setting data is the different nature of the contents they set to the app.
getField()  : Field
Returns the field this adapter holds data for. This is important for the database driver as it will have to locate the field where it has to place this data.
getModel()  : Model
This method should return the model / record this belongs to. This allows for checking against other database data (in case this is needed) and several operations that are critical for the systems correct behavior.
isSynced()  : bool
Allows the adapter to tell the database driver whether the data inside this is synced (has not been modified) and should be stored to the database to avoid being lost.
rollback()  : mixed
Resets the content inside the adapter. In case you don't want to keep the altered data and want to modify or read the original source data instead of the altered one.
usrGetData()  : mixed
Returns the data that is meant to reach the 'user space'. Objects here should be programmer friendly and can be objects if needed.
usrSetData()  : mixed
This method sets the data from the 'user' end. This means the opposite one to the database, the one being moved into the database.

Methods

commit()

Settles the content inside the adapter. This method is usually called when the model is being stored. This means the data is considered final and the data inside the adapter is no longer out of sync with the database.

public commit() : mixed

In case the data is not stored inside the database you can use the commit function to do so, as this is called even if the adapter is in sync.

Return values
mixed

dbGetData()

This method returns the data the adapter wants to store to the database. The DBMS controller should use this endpoint to collect the data it will store to the driver.

public dbGetData() : mixed
Return values
mixed

Data to be contained in the database.

dbSetData()

This receives data from the database and stores it into the adapter. The reason there are two methods for setting data is the different nature of the contents they set to the app.

public dbSetData(mixed $data) : mixed
Parameters
$data : mixed

Data to be stored to the adapter.

Return values
mixed

getField()

Returns the field this adapter holds data for. This is important for the database driver as it will have to locate the field where it has to place this data.

public getField() : Field
Return values
Field

The field this represents

getModel()

This method should return the model / record this belongs to. This allows for checking against other database data (in case this is needed) and several operations that are critical for the systems correct behavior.

public getModel() : Model
Return values
Model

The model this belongs to.

isSynced()

Allows the adapter to tell the database driver whether the data inside this is synced (has not been modified) and should be stored to the database to avoid being lost.

public isSynced() : bool

If data considers itself non-DB friendly (like arrays / subrecords /etc) these should return false always and use the commit method to store the data.

Return values
bool

Indicates whether the data is already in sync. Returns false if it should be stored.

rollback()

Resets the content inside the adapter. In case you don't want to keep the altered data and want to modify or read the original source data instead of the altered one.

public rollback() : mixed
Return values
mixed

usrGetData()

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

public usrGetData() : mixed

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

Return values
mixed

Data to be delivered to the programmer

usrSetData()

This method sets the data from the 'user' end. This means the opposite one to the database, the one being moved into the database.

public usrSetData(mixed $data) : mixed

You can and should use this method to allow verifying that the data sent by the user is correct here, there is no need to check it's database friendliness here (this could even be bad for performance).

Parameters
$data : mixed

Data to be contained in the database.

Return values
mixed

Search results