FacturaScripts

CodeModel
in package

Auxiliary model to load a list of codes and their descriptions

Table of Contents

Constants

ALL_LIMIT  = 1000
MODEL_NAMESPACE  = '\FacturaScripts\Dinamic\Model\\'
SEARCH_LIMIT  = 50

Properties

$code  : string
$description  : string
$dataBase  : DataBase
$limit  : int

Methods

__construct()  : mixed
all()  : array<string|int, static>
Load a CodeModel list (code and description) for the indicated table.
array2codeModel()  : array<string|int, static>
Convert an associative array (code and value) into a CodeModel array.
get()  : static
Returns a codemodel with the selected data.
getDescription()  : string
Returns a description with the selected data.
getLimit()  : int
search()  : array<string|int, static>
Load a CodeModel list (code and description) for the indicated table and search.
setLimit()  : void
db()  : DataBase
isValidFieldName()  : bool
Valida que un nombre de campo sea seguro para usar en consultas SQL.
isValidTableName()  : bool
Valida que un nombre de tabla sea seguro para usar en consultas SQL.
codeModelAll()  : array<string|int, mixed>
codeModelSearch()  : array<string|int, mixed>

Constants

MODEL_NAMESPACE

public mixed MODEL_NAMESPACE = '\FacturaScripts\Dinamic\Model\\'

Properties

Methods

__construct()

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

all()

Load a CodeModel list (code and description) for the indicated table.

public static all(string $tableName, string $fieldCode, string $fieldDescription[, bool $addEmpty = true ][, array<string|int, mixed> $where = [] ]) : array<string|int, static>
Parameters
$tableName : string
$fieldCode : string
$fieldDescription : string
$addEmpty : bool = true
$where : array<string|int, mixed> = []
Return values
array<string|int, static>

array2codeModel()

Convert an associative array (code and value) into a CodeModel array.

public static array2codeModel(array<string|int, mixed> $data[, bool $addEmpty = true ]) : array<string|int, static>
Parameters
$data : array<string|int, mixed>
$addEmpty : bool = true
Return values
array<string|int, static>

get()

Returns a codemodel with the selected data.

public get(string $tableName, string $fieldCode, string $code, string $fieldDescription) : static
Parameters
$tableName : string
$fieldCode : string
$code : string
$fieldDescription : string
Return values
static

getDescription()

Returns a description with the selected data.

public getDescription(string $tableName, string $fieldCode, string $code, string $fieldDescription) : string
Parameters
$tableName : string
$fieldCode : string
$code : string
$fieldDescription : string
Return values
string

getLimit()

public static getLimit() : int
Return values
int

Load a CodeModel list (code and description) for the indicated table and search.

public static search(string $tableName, string $fieldCode, string $fieldDescription, string $query[, array<string|int, Where$where = [] ]) : array<string|int, static>
Parameters
$tableName : string
$fieldCode : string
$fieldDescription : string
$query : string
$where : array<string|int, Where> = []
Return values
array<string|int, static>

setLimit()

public static setLimit(int $newLimit) : void
Parameters
$newLimit : int

isValidFieldName()

Valida que un nombre de campo sea seguro para usar en consultas SQL.

protected static isValidFieldName(string $fieldName) : bool

Solo permite letras, números, guiones bajos y puntos (para campos con alias de tabla). También permite el uso de las funciones lower(), upper(), substring() y concat().

Parameters
$fieldName : string
Return values
bool

isValidTableName()

Valida que un nombre de tabla sea seguro para usar en consultas SQL.

protected static isValidTableName(string $tableName) : bool

Solo permite letras, números y guiones bajos.

Parameters
$tableName : string
Return values
bool

codeModelAll()

private static codeModelAll(mixed $model, string $fieldCode) : array<string|int, mixed>
Parameters
$model : mixed
$fieldCode : string
Return values
array<string|int, mixed>

codeModelSearch()

private static codeModelSearch(mixed $model, string $query, string $fieldCode, array<string|int, mixed> $where) : array<string|int, mixed>
Parameters
$model : mixed
$query : string
$fieldCode : string
$where : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results