JoinModel
in package
The class from which all views of the model are inherited.
It allows the visualization of data of several tables of the database. This type of model is only for reading data, it does not allow modification or deletion of data directly.
A main model ("master") must be indicated, which will be responsible for executing the data modification actions. This means that when inserting, modifying or deleting, only the operation on the indicated master model is performed.
Tags
Table of Contents
- $dataBase : DataBase
- It provides direct access to the database.
- $masterModel : ModelClass
- Master model
- $values : array<string|int, mixed>
- List of values for record view
- __construct() : mixed
- Constructor and class initializer.
- __get() : mixed
- Return model view field value
- __isset() : bool
- Check if exits value to property
- __set() : mixed
- Set value to model view field
- all() : array<string|int, static>
- Load data for the indicated where.
- clear() : mixed
- Reset the values of all model properties.
- count() : int
- Returns the number of records that meet the condition.
- delete() : bool
- Remove the model master data from the database.
- exists() : bool
- Returns true if the model data is stored in the database.
- getModelFields() : array<string|int, mixed>
- loadFromCode() : bool
- Fill the class with the registry values whose primary column corresponds to the value $cod, or according to the condition where indicated, if value is not reported in $cod.
- primaryColumnValue() : mixed
- Gets the value from model view cursor of the master model primary key.
- url() : string
- Returns the url where to see / modify the data.
- getFields() : array<string|int, mixed>
- List of fields or columns to select clausule
- getGroupFields() : string
- Return Group By fields
- getSQLFrom() : string
- List of tables related to from clausule
- getTables() : array<string|int, mixed>
- List of tables required for the execution of the view.
- loadFromData() : mixed
- Assign the values of the $data array to the model view properties.
- setMasterModel() : mixed
- Sets the master model for data operations
- toolBox() : ToolBox
- checkTables() : bool
- Check list of tables required.
- fieldsList() : string
- Convert the list of fields into a string to use as a select clause
- getGroupBy() : string
- Return Group By clausule
- getOrderBy() : string
- Convert an array of filters order by in string.
- loadFilterWhere() : bool
- If a value is reported for the PK create a database where for the master key of the master model.
Properties
$dataBase
It provides direct access to the database.
protected
static DataBase
$dataBase
$masterModel
Master model
protected
ModelClass
$masterModel
$values
List of values for record view
private
array<string|int, mixed>
$values
= []
Methods
__construct()
Constructor and class initializer.
public
__construct([array<string|int, mixed> $data = [] ]) : mixed
Parameters
- $data : array<string|int, mixed> = []
Return values
mixed —__get()
Return model view field value
public
__get(string $name) : mixed
Parameters
- $name : string
Return values
mixed —__isset()
Check if exits value to property
public
__isset(string $name) : bool
Parameters
- $name : string
Return values
bool —__set()
Set value to model view field
public
__set(string $name, mixed $value) : mixed
Parameters
- $name : string
- $value : mixed
Return values
mixed —all()
Load data for the indicated where.
public
all(array<string|int, DataBaseWhere> $where[, array<string|int, mixed> $order = [] ], int $offset, int $limit) : array<string|int, static>
Parameters
- $where : array<string|int, DataBaseWhere>
-
filters to apply to model records.
- $order : array<string|int, mixed> = []
-
fields to use in the sorting. For example ['code' => 'ASC']
- $offset : int
- $limit : int
Return values
array<string|int, static> —clear()
Reset the values of all model properties.
public
clear() : mixed
Return values
mixed —count()
Returns the number of records that meet the condition.
public
count([array<string|int, DataBaseWhere> $where = [] ]) : int
Parameters
- $where : array<string|int, DataBaseWhere> = []
-
filters to apply to records.
Return values
int —delete()
Remove the model master data from the database.
public
delete() : bool
Return values
bool —exists()
Returns true if the model data is stored in the database.
public
exists() : bool
Return values
bool —getModelFields()
public
getModelFields() : array<string|int, mixed>
Return values
array<string|int, mixed> —loadFromCode()
Fill the class with the registry values whose primary column corresponds to the value $cod, or according to the condition where indicated, if value is not reported in $cod.
public
loadFromCode(string $cod[, array<string|int, mixed> $where = [] ][, array<string|int, mixed> $orderby = [] ]) : bool
Initializes the values of the class if there is no record that meet the above conditions. Returns True if the record exists and False otherwise.
Parameters
- $cod : string
- $where : array<string|int, mixed> = []
- $orderby : array<string|int, mixed> = []
Return values
bool —primaryColumnValue()
Gets the value from model view cursor of the master model primary key.
public
primaryColumnValue() : mixed
Return values
mixed —url()
Returns the url where to see / modify the data.
public
url([string $type = 'auto' ][, string $list = 'List' ]) : string
Parameters
- $type : string = 'auto'
- $list : string = 'List'
Return values
string —getFields()
List of fields or columns to select clausule
protected
abstract getFields() : array<string|int, mixed>
Return values
array<string|int, mixed> —getGroupFields()
Return Group By fields
protected
getGroupFields() : string
Return values
string —getSQLFrom()
List of tables related to from clausule
protected
abstract getSQLFrom() : string
Return values
string —getTables()
List of tables required for the execution of the view.
protected
abstract getTables() : array<string|int, mixed>
Return values
array<string|int, mixed> —loadFromData()
Assign the values of the $data array to the model view properties.
protected
loadFromData(array<string|int, mixed> $data) : mixed
Parameters
- $data : array<string|int, mixed>
Return values
mixed —setMasterModel()
Sets the master model for data operations
protected
setMasterModel(ModelClass $model) : mixed
Parameters
- $model : ModelClass
Return values
mixed —toolBox()
protected
toolBox() : ToolBox
Tags
Return values
ToolBox —checkTables()
Check list of tables required.
private
checkTables() : bool
Return values
bool —fieldsList()
Convert the list of fields into a string to use as a select clause
private
fieldsList() : string
Return values
string —getGroupBy()
Return Group By clausule
private
getGroupBy() : string
Return values
string —getOrderBy()
Convert an array of filters order by in string.
private
getOrderBy(array<string|int, mixed> $order) : string
Parameters
- $order : array<string|int, mixed>
Return values
string —loadFilterWhere()
If a value is reported for the PK create a database where for the master key of the master model.
private
loadFilterWhere(string $cod, array<string|int, mixed> &$where) : bool
Parameters
- $cod : string
- $where : array<string|int, mixed>