FacturaScripts

ModelCore
in package

AbstractYes

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

Use FacturaScripts\Core\Template\ModelClass instead

Table of Contents

Constants

AUDIT_CHANNEL  = 'audit'
DATE_STYLE  = 'd-m-Y'
DATETIME_STYLE  = 'd-m-Y H:i:s'
HOUR_STYLE  = 'H:i:s'

Properties

$dataBase  : DataBase
It provides direct access to the database.

Methods

__construct()  : mixed
ModelClass constructor.
addExtension()  : mixed
Adds an extension to this model.
changePrimaryColumnValue()  : bool
Change the value of the primary column in the model and the database.
clear()  : mixed
Reset the values of all model properties.
getModelFields()  : array<string|int, mixed>
Returns the list of fields in the table.
hasExtension()  : bool
Returns true if the extension exists.
install()  : string
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.
loadFromData()  : mixed
Assign the values of the $data array to the model properties.
modelClassName()  : string
Returns the name of the class of the model.
pipe()  : mixed
Executes all $name methods added from the extensions.
pipeFalse()  : bool
Executes all $name methods added from the extensions until someone returns false.
primaryColumn()  : string
Returns the name of the column that is the model's primary key.
primaryColumnValue()  : mixed
Returns the current value of the main column of the model.
tableName()  : string
Returns the name of the table that uses this model.
toArray()  : array<string|int, mixed>
Returns an array with the model fields values.
loadModelFields()  : mixed
Loads table fields if is necessary.
modelName()  : string
Returns the name of the model.
getBoolValueForField()  : bool|null
Returns the boolean value for the field.
getFloatValueForField()  : float|null
Returns the float value for the field.
getIntegerValueForField()  : int|null
Returns the integer value by controlling special cases for the PK and FK.

Constants

AUDIT_CHANNEL

public mixed AUDIT_CHANNEL = 'audit'

DATE_STYLE

public mixed DATE_STYLE = 'd-m-Y'

DATETIME_STYLE

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

HOUR_STYLE

public mixed HOUR_STYLE = 'H:i:s'

Properties

$dataBase

It provides direct access to the database.

protected static DataBase $dataBase

Methods

__construct()

ModelClass constructor.

public __construct([array<string|int, mixed> $data = [] ]) : mixed
Parameters
$data : array<string|int, mixed> = []

addExtension()

Adds an extension to this model.

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

changePrimaryColumnValue()

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

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

clear()

Reset the values of all model properties.

public clear() : mixed

getModelFields()

Returns the list of fields in the table.

public abstract getModelFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

hasExtension()

Returns true if the extension exists.

public abstract hasExtension(mixed $extension) : bool
Parameters
$extension : mixed
Return values
bool

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([array<string|int, mixed> $data = [] ][, array<string|int, mixed> $exclude = [] ]) : mixed
Parameters
$data : array<string|int, mixed> = []
$exclude : array<string|int, mixed> = []

modelClassName()

Returns the name of the class of the model.

public abstract modelClassName() : string
Return values
string

pipe()

Executes all $name methods added from the extensions.

public abstract pipe(string $name, array<string|int, mixed> ...$arguments) : mixed
Parameters
$name : string
$arguments : array<string|int, mixed>

pipeFalse()

Executes all $name methods added from the extensions until someone returns false.

public abstract pipeFalse(string $name, array<string|int, mixed> ...$arguments) : bool
Parameters
$name : string
$arguments : array<string|int, mixed>
Return values
bool

primaryColumn()

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

public abstract static primaryColumn() : string
Return values
string

primaryColumnValue()

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

public primaryColumnValue() : mixed

tableName()

Returns the name of the table that uses this model.

public abstract static tableName() : string
Return values
string

toArray()

Returns an array with the model fields values.

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

loadModelFields()

Loads table fields if is necessary.

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

modelName()

Returns the name of the model.

protected abstract modelName() : string
Return values
string

getBoolValueForField()

Returns the boolean value for the field.

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

getFloatValueForField()

Returns the float value for the field.

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

getIntegerValueForField()

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

private getIntegerValueForField(array<string|int, mixed> $field, string $value) : int|null
Parameters
$field : array<string|int, mixed>
$value : string
Return values
int|null

        
On this page

Search results