AttachedFile
        
        extends AttachedFile
    
    
            
            in package
            
        
    
    
    
        
            Class created by Core/Base/PluginDeploy
Tags
Table of Contents
- AUDIT_CHANNEL = 'audit'
 - DATE_STYLE = 'd-m-Y'
 - DATETIME_STYLE = 'd-m-Y H:i:s'
 - HOUR_STYLE = 'H:i:s'
 - MAX_FILENAME_LEN = 100
 - STORAGE_USED_KEY = 'storage-used'
 - $date : string
 - $filename : string
 - $hour : string
 - $idfile : int
 - $mimetype : string
 - $path : string
 - $size : int
 - $dataBase : DataBase
 - It provides direct access to the database.
 - $fields : array<string|int, mixed>
 - List of fields in the table.
 - $previousData : array<string|int, mixed>
 - Previous data array.
 - __construct() : mixed
 - ModelClass constructor.
 - addExtension() : mixed
 - Adds an extension to this model.
 - all() : array<string|int, static>
 - Returns all models that correspond to the selected filters.
 - changePrimaryColumnValue() : bool
 - Change the value of the primary column in the model and the database.
 - clear() : mixed
 - Reset the values of all model properties.
 - codeModelAll() : array<string|int, CodeModel>
 - Allows to use this model as source in CodeModel special model.
 - codeModelSearch() : array<string|int, CodeModel>
 - Allows to use this model as source in CodeModel special model.
 - count() : int
 - Returns the number of records in the model that meet the condition.
 - delete() : bool
 - Remove the model data from the database.
 - exists() : bool
 - Returns true if the model data is stored in the database.
 - get() : static|false
 - Returns the model whose primary column corresponds to the value $cod
 - getExtension() : string
 - getFullPath() : string
 - getModelFields() : array<string|int, mixed>
 - Returns the list of fields in the table.
 - getStorageLimit() : int
 - getStorageUsed() : int
 - hasChanged() : bool
 - 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.
 - isArchive() : bool
 - isImage() : bool
 - isPdf() : bool
 - isVideo() : bool
 - 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.
 - loadFromData() : mixed
 - Assign the values of the $data array to the model properties.
 - modelClassName() : string
 - Returns the name of the class of the model.
 - newCode() : int
 - Returns the following code for the reported field or the primary key 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.
 - primaryDescription() : string
 - Descriptive identifier for humans of the data record
 - primaryDescriptionColumn() : string
 - Returns the name of the column that describes the model, such as name, description.
 - save() : bool
 - Stores the model data in the database.
 - shortFileName() : string
 - table() : DbQuery
 - tableName() : string
 - Returns the name of the table that uses this model.
 - test() : bool
 - Returns true if there are no errors in the values of the model properties.
 - toArray() : array<string|int, mixed>
 - Returns an array with the model fields values.
 - totalSum() : float
 - url() : string
 - Returns the url where to see / modify the data.
 - fixFileName() : string
 - getNextCode() : int
 - loadModelFields() : mixed
 - Loads table fields if is necessary.
 - modelName() : string
 - Returns the name of the model.
 - onChange() : bool
 - This method is called before save (update) when some field has changed.
 - onDelete() : mixed
 - This method is called after a record is removed from the database.
 - onInsert() : mixed
 - This method is called after a new record is saved on the database (saveInsert).
 - onUpdate() : mixed
 - This method is called after a record is updated on the database (saveUpdate).
 - saveInsert() : bool
 - Insert the model data in the database.
 - saveUpdate() : bool
 - Update the model data in the database.
 - setFile() : bool
 - Examine and move new file set.
 - setPreviousData() : mixed
 - Saves previous values.
 - toolBox() : ToolBox
 - Returns a new instance of the ToolBox class.
 - 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.
 - getOrderBy() : string
 - Convert an array of filters order by in string.
 - getRecord() : array<string|int, mixed>
 - Read the record whose primary column corresponds to the value $cod or the first that meets the indicated condition.
 
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'
        
        
    
MAX_FILENAME_LEN
    public
        mixed
    MAX_FILENAME_LEN
    = 100
        
        
    
STORAGE_USED_KEY
    public
        mixed
    STORAGE_USED_KEY
    = 'storage-used'
        
        
    
Properties
$date
    public
        string
    $date
    
    
    
    
$filename
    public
        string
    $filename
    
    
    
    
$hour
    public
        string
    $hour
    
    
    
    
$idfile
    public
        int
    $idfile
    
    
    
    
$mimetype
    public
        string
    $mimetype
    
    
    
    
$path
    public
        string
    $path
    
    
    
    
$size
    public
        int
    $size
    
    
    
    
$dataBase
It provides direct access to the database.
    protected
    static    DataBase
    $dataBase
    
    
    
    
$fields
List of fields in the table.
    protected
    static    array<string|int, mixed>
    $fields
     = []
    
    
    
$previousData
Previous data array.
    protected
        array<string|int, mixed>
    $previousData
     = []
    
    
    
Methods
__construct()
ModelClass constructor.
    public
                    __construct([array<string|int, mixed> $data = [] ]) : mixed
    
        Parameters
- $data : array<string|int, mixed> = []
 
Return values
mixed —addExtension()
Adds an extension to this model.
    public
    abstract        static        addExtension(mixed $extension) : mixed
    
        Parameters
- $extension : mixed
 
Return values
mixed —all()
Returns all models that correspond to the selected filters.
    public
            static        all([array<string|int, mixed> $where = [] ][, array<string|int, mixed> $order = [] ], int $offset[, int $limit = 50 ]) : array<string|int, static>
    
        Parameters
- $where : array<string|int, mixed> = []
 - 
                    
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 = 50
 
Return values
array<string|int, static> —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
    
    
    
        Return values
mixed —codeModelAll()
Allows to use this model as source in CodeModel special model.
    public
                    codeModelAll([string $fieldCode = '' ]) : array<string|int, CodeModel>
    
        Parameters
- $fieldCode : string = ''
 
Return values
array<string|int, CodeModel> —codeModelSearch()
Allows to use this model as source in CodeModel special model.
    public
                    codeModelSearch(string $query[, string $fieldCode = '' ][, array<string|int, DataBaseWhere> $where = [] ]) : array<string|int, CodeModel>
    
        Parameters
- $query : string
 - $fieldCode : string = ''
 - $where : array<string|int, DataBaseWhere> = []
 
Return values
array<string|int, CodeModel> —count()
Returns the number of records in the model that meet the condition.
    public
                    count([array<string|int, DataBaseWhere> $where = [] ]) : int
    
        Parameters
- $where : array<string|int, DataBaseWhere> = []
 - 
                    
filters to apply to model records.
 
Return values
int —delete()
Remove the model 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 —get()
Returns the model whose primary column corresponds to the value $cod
    public
                    get(string $code) : static|false
    
        Parameters
- $code : string
 
Return values
static|false —getExtension()
    public
                    getExtension() : string
        
    
    
        Return values
string —getFullPath()
    public
                    getFullPath() : string
        
    
    
        Return values
string —getModelFields()
Returns the list of fields in the table.
    public
    abstract                getModelFields() : array<string|int, mixed>
    
    
    
        Return values
array<string|int, mixed> —getStorageLimit()
    public
            static        getStorageLimit() : int
        
    
    
        Return values
int —getStorageUsed()
    public
            static        getStorageUsed([array<string|int, mixed> $exclude = [] ]) : int
        
        Parameters
- $exclude : array<string|int, mixed> = []
 
Return values
int —hasChanged()
    public
                    hasChanged(string $field) : bool
        
        Parameters
- $field : string
 
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 —isArchive()
    public
                    isArchive() : bool
        
    
    
        Return values
bool —isImage()
    public
                    isImage() : bool
        
    
    
        Return values
bool —isPdf()
    public
                    isPdf() : bool
        
    
    
        Return values
bool —isVideo()
    public
                    isVideo() : bool
        
    
    
        Return values
bool —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 $code[, array<string|int, mixed> $where = [] ][, array<string|int, mixed> $order = [] ]) : 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
- $code : string
 - $where : array<string|int, mixed> = []
 - $order : array<string|int, mixed> = []
 
Return values
bool —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> = []
 
Return values
mixed —modelClassName()
Returns the name of the class of the model.
    public
    abstract                modelClassName() : string
    
    
    
        Return values
string —newCode()
Returns the following code for the reported field or the primary key of the model.
    public
                    newCode([string $field = '' ][, array<string|int, mixed> $where = [] ]) : int
    
        Parameters
- $field : string = ''
 - $where : array<string|int, mixed> = []
 
Return values
int —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>
 
Return values
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
    
    
    
        Return values
mixed —primaryDescription()
Descriptive identifier for humans of the data record
    public
                    primaryDescription() : string
    
    
    
        Return values
string —primaryDescriptionColumn()
Returns the name of the column that describes the model, such as name, description.
    public
                    primaryDescriptionColumn() : string
        ..
Return values
string —save()
Stores the model data in the database.
    public
                    save() : bool
    
    
    
        Return values
bool —shortFileName()
    public
                    shortFileName([int $length = 20 ]) : string
        
        Parameters
- $length : int = 20
 
Return values
string —table()
    public
            static        table() : DbQuery
        
    
    
        Return values
DbQuery —tableName()
Returns the name of the table that uses this model.
    public
    abstract        static        tableName() : string
    
    
    
        Return values
string —test()
Returns true if there are no errors in the values of the model properties.
    public
                    test() : bool
        It runs inside the save method.
Return values
bool —toArray()
Returns an array with the model fields values.
    public
                    toArray() : array<string|int, mixed>
    
    
    
        Return values
array<string|int, mixed> —totalSum()
    public
                    totalSum(string $field[, array<string|int, mixed> $where = [] ]) : float
        
        Parameters
- $field : string
 - $where : array<string|int, mixed> = []
 
Return values
float —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 —fixFileName()
    protected
                    fixFileName(string $original) : string
        
        Parameters
- $original : string
 
Return values
string —getNextCode()
    protected
                    getNextCode() : int
        
    
    
        Return values
int —loadModelFields()
Loads table fields if is necessary.
    protected
    abstract                loadModelFields(DataBase &$dataBase, string $tableName) : mixed
    
        Parameters
- $dataBase : DataBase
 - $tableName : string
 
Return values
mixed —modelName()
Returns the name of the model.
    protected
    abstract                modelName() : string
    
    
    
        Return values
string —onChange()
This method is called before save (update) when some field has changed.
    protected
                    onChange(string $field) : bool
    
        Parameters
- $field : string
 
Return values
bool —onDelete()
This method is called after a record is removed from the database.
    protected
                    onDelete() : mixed
    
    
    
        Return values
mixed —onInsert()
This method is called after a new record is saved on the database (saveInsert).
    protected
                    onInsert() : mixed
    
    
    
        Return values
mixed —onUpdate()
This method is called after a record is updated on the database (saveUpdate).
    protected
                    onUpdate() : mixed
    
    
    
        Return values
mixed —saveInsert()
Insert the model data in the database.
    protected
                    saveInsert([array<string|int, mixed> $values = [] ]) : bool
    
        Parameters
- $values : array<string|int, mixed> = []
 
Return values
bool —saveUpdate()
Update the model data in the database.
    protected
                    saveUpdate([array<string|int, mixed> $values = [] ]) : bool
    
        Parameters
- $values : array<string|int, mixed> = []
 
Return values
bool —setFile()
Examine and move new file set.
    protected
                    setFile() : bool
    
    
    
        Return values
bool —setPreviousData()
Saves previous values.
    protected
                    setPreviousData([array<string|int, mixed> $fields = [] ]) : mixed
    
        Parameters
- $fields : array<string|int, mixed> = []
 
Return values
mixed —toolBox()
Returns a new instance of the ToolBox class.
    protected
            static        toolBox() : ToolBox
    
    
    
    Tags
Return values
ToolBox —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 —getOrderBy()
Convert an array of filters order by in string.
    private
            static        getOrderBy(array<string|int, mixed> $order) : string
    
        Parameters
- $order : array<string|int, mixed>
 
Return values
string —getRecord()
Read the record whose primary column corresponds to the value $cod or the first that meets the indicated condition.
    private
                    getRecord(string $code[, array<string|int, mixed> $where = [] ][, array<string|int, mixed> $order = [] ]) : array<string|int, mixed>
    
        Parameters
- $code : string
 - $where : array<string|int, mixed> = []
 - $order : array<string|int, mixed> = []