FacturaScripts

ModelCore

The class from which all models inherit, connects to the database, check the structure of the table and if necessary create or adapt.

Table of Contents

DATE_STYLE 'd-m-Y'
DATETIME_STYLE 'd-m-Y H:i:s'
HOUR_STYLE 'H:i:s'
$checkedTables List of already tested tables. array
$dataBase It provides direct access to the database. DataBase
addExtension() Adds an extension to this model. mixed
getModelFields() Returns the list of fields in the table. array
loadModelFields() Loads table fields if is necessary. mixed
modelClassName() Returns the name of the class of the model. string
modelName() Returns the name of the model. string
pipe() Executes all $name methods added from the extensions. mixed
primaryColumn() Returns the name of the column that is the model's primary key. string
tableName() Returns the name of the table that uses this model. string
__construct() ModelClass constructor. mixed
changePrimaryColumnValue() Change the value of the primary column in the model and the database. bool
clear() Reset the values of all model properties. mixed
install() This function is called when creating the model table. Returns the SQL that will be executed after the creation of the table. Useful to insert values default. string
loadFromData() Assign the values of the $data array to the model properties. mixed
primaryColumnValue() Returns the current value of the main column of the model. mixed
toArray() Returns an array with the model fields values. array
checkTable() Checks and updates the structure of the table if necessary. bool
getBoolValueForField() Returns the boolean value for the field. bool|null
getFloatValueForField() Returns the float value for the field. float|null
getIntergerValueForField() Returns the integer value by controlling special cases for the PK and FK. int|null
toolBox() ToolBox

Constants

DATETIME_STYLE

mixed $DATETIME_STYLE = 'd-m-Y H:i:s'

Properties

$checkedTables

List of already tested tables.

private static array $checkedTables = []

$dataBase

It provides direct access to the database.

protected static DataBase $dataBase

Methods

addExtension()

Adds an extension to this model.

public abstract static addExtension( $extension : mixed ) : mixed
Parameters
$extension : mixed
Return values
mixed

getModelFields()

Returns the list of fields in the table.

public abstract getModelFields( ) : array
Return values
array

loadModelFields()

Loads table fields if is necessary.

protected abstract loadModelFields( &$dataBase : DataBase , $tableName : string ) : mixed
Parameters
$dataBase : DataBase
$tableName : string
Return values
mixed

modelClassName()

Returns the name of the class of the model.

public abstract modelClassName( ) : string
Return values
string

modelName()

Returns the name of the model.

protected abstract modelName( ) : string
Return values
string

pipe()

Executes all $name methods added from the extensions.

public abstract pipe( $name : string , ...$arguments : array ) : mixed
Parameters
$name : string
$arguments : array
Return values
mixed

primaryColumn()

Returns the name of the column that is the model's primary key.

public abstract static primaryColumn( ) : string
Return values
string

tableName()

Returns the name of the table that uses this model.

public abstract static tableName( ) : string
Return values
string

__construct()

ModelClass constructor.

public __construct( [ $data : array = [] ] ) : mixed
Parameters
$data : array = []
Return values
mixed

changePrimaryColumnValue()

Change the value of the primary column in the model and the database.

public changePrimaryColumnValue( $newValue : mixed ) : bool
Parameters
$newValue : mixed
Return values
bool

clear()

Reset the values of all model properties.

public clear( ) : mixed
Return values
mixed

install()

This function is called when creating the model table. Returns the SQL that will be executed after the creation of the table. Useful to insert values default.

public install( ) : string
Return values
string

loadFromData()

Assign the values of the $data array to the model properties.

public loadFromData( [ $data : array = [] ] [, $exclude : array = [] ] ) : mixed
Parameters
$data : array = []
$exclude : array = []
Return values
mixed

primaryColumnValue()

Returns the current value of the main column of the model.

public primaryColumnValue( ) : mixed
Return values
mixed

toArray()

Returns an array with the model fields values.

public toArray( ) : array
Return values
array

checkTable()

Checks and updates the structure of the table if necessary.

private checkTable( ) : bool
Return values
bool

getBoolValueForField()

Returns the boolean value for the field.

private getBoolValueForField( $field : array , $value : string ) : bool|null
Parameters
$field : array
$value : string
Return values
bool|null

getFloatValueForField()

Returns the float value for the field.

private getFloatValueForField( $field : array , $value : string ) : float|null
Parameters
$field : array
$value : string
Return values
float|null

getIntergerValueForField()

Returns the integer value by controlling special cases for the PK and FK.

private getIntergerValueForField( $field : array , $value : string ) : int|null
Parameters
$field : array
$value : string
Return values
int|null

Search results