FacturaScripts

TotalModel

Auxiliary model to load a list of totals with or without grouping by code.

Table of Contents

$dataBase It provides direct access to the database. DataBase
$code Value of the code field of the model read. string
$totals Total values of the fields of the read model. array
__construct() Constructor and class initializer mixed
all() Load a list of TotalModel (code and fields of statistics) for the indicated table. static[]
clearTotals() Reset the totals to 0.0 mixed
sum() float
dataBase() DataBase
getFieldSQL() Returns the / fields as part of the SQL query. string

Properties

$code

Value of the code field of the model read.

public string $code

$totals

Total values of the fields of the read model.

public array $totals

Methods

__construct()

Constructor and class initializer

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

all()

Load a list of TotalModel (code and fields of statistics) for the indicated table.

public static all( $tableName : string , $where : \FacturaScripts\Core\Base\DataBase\DataBaseWhere[] , $fieldList : array [, $fieldCode : string = '' ] ) : static[]
Parameters
$tableName : string
$where : \FacturaScripts\Core\Base\DataBase\DataBaseWhere[]
$fieldList : array

(['key' => 'SUM(total)', 'key2' => 'MAX(total)' ...])

$fieldCode : string = ''

(for multiples rows agruped by field code)

Return values
static[]

clearTotals()

Reset the totals to 0.0

public clearTotals( $totalFields : array ) : mixed
Parameters
$totalFields : array
Return values
mixed

sum()

public static sum( $tableName : string , $fieldName : string , $where : \FacturaScripts\Core\Base\DataBase\DataBaseWhere[] ) : float
Parameters
$tableName : string
$fieldName : string
$where : \FacturaScripts\Core\Base\DataBase\DataBaseWhere[]
Return values
float

getFieldSQL()

Returns the / fields as part of the SQL query.

private static getFieldSQL( $fieldCode : string , $fieldList : array ) : string
Parameters
$fieldCode : string
$fieldList : array
Return values
string

Search results