DataBaseWhere
in package
Structure that defines a WHERE condition to filter the model data
Tags
Table of Contents
- $fields : string
- Field list to apply the filters to, separated by '|'.
- $operation : string
- Logic operator that will be applied to the condition.
- $operator : string
- Arithmetic operator that is being used.
- $value : mixed
- Filter value.
- $dataBase : DataBase
- Link with the active database.
- __construct() : mixed
- DataBaseWhere constructor.
- applyOperation() : array<string|int, mixed>
- Given a list of fields with operators: '|' for OR operations ',' for AND operations Returns an array with the field (key) and the operation (value).
- getFieldsFilter() : array<string|int, mixed>
- Given a DataBaseWhere array, it returns the field list with their values that will be applied as a filter. (It only returns filters with the '=' operator).
- getSQLWhere() : string
- Given a DataBaseWhere array, it returns the full WHERE clause.
- getSQLWhereItem() : string
- Returns a string to apply to the WHERE clause.
- applyValueToFields() : string
- Apply one value to a field list.
- escapeColumn() : string
- getGroupPrefix() : string
- Calculate if you need grouping of conditions.
- getValue() : string
- Returns the filter value formatted according to the type.
- getValueFromOperator() : string
- Returns the value for the operator.
- getValueFromOperatorIn() : string
- Return list values for IN operator.
- getValueFromOperatorLike() : string
- Return value for LIKE operator.
Properties
$fields
Field list to apply the filters to, separated by '|'.
public
string
$fields
$operation
Logic operator that will be applied to the condition.
public
string
$operation
$operator
Arithmetic operator that is being used.
public
string
$operator
$value
Filter value.
public
mixed
$value
$dataBase
Link with the active database.
private
DataBase
$dataBase
Methods
__construct()
DataBaseWhere constructor.
public
__construct(string $fields, mixed $value[, string $operator = '=' ][, string $operation = 'AND' ]) : mixed
Parameters
- $fields : string
- $value : mixed
- $operator : string = '='
- $operation : string = 'AND'
Return values
mixed —applyOperation()
Given a list of fields with operators: '|' for OR operations ',' for AND operations Returns an array with the field (key) and the operation (value).
public
static applyOperation(string $fields) : array<string|int, mixed>
Parameters
- $fields : string
Return values
array<string|int, mixed> —getFieldsFilter()
Given a DataBaseWhere array, it returns the field list with their values that will be applied as a filter. (It only returns filters with the '=' operator).
public
static getFieldsFilter(array<string|int, mixed> $whereItems) : array<string|int, mixed>
Parameters
- $whereItems : array<string|int, mixed>
Return values
array<string|int, mixed> —getSQLWhere()
Given a DataBaseWhere array, it returns the full WHERE clause.
public
static getSQLWhere(array<string|int, DataBaseWhere> $whereItems) : string
Parameters
- $whereItems : array<string|int, DataBaseWhere>
Return values
string —getSQLWhereItem()
Returns a string to apply to the WHERE clause.
public
getSQLWhereItem([bool $applyOperation = false ][, string $prefix = '' ]) : string
Parameters
- $applyOperation : bool = false
- $prefix : string = ''
Return values
string —applyValueToFields()
Apply one value to a field list.
private
applyValueToFields(mixed $value, array<string|int, mixed> $fields) : string
Parameters
- $value : mixed
- $fields : array<string|int, mixed>
Return values
string —escapeColumn()
private
escapeColumn(string $column) : string
Parameters
- $column : string
Return values
string —getGroupPrefix()
Calculate if you need grouping of conditions.
private
static getGroupPrefix(DataBaseWhere $item, bool &$group) : string
It is necessary for logical conditions of type 'OR'
Parameters
- $item : DataBaseWhere
- $group : bool
Return values
string —getValue()
Returns the filter value formatted according to the type.
private
getValue(string $value) : string
Parameters
- $value : string
Return values
string —getValueFromOperator()
Returns the value for the operator.
private
getValueFromOperator(string $value) : string
Parameters
- $value : string
Return values
string —getValueFromOperatorIn()
Return list values for IN operator.
private
getValueFromOperatorIn(string $values) : string
Parameters
- $values : string
Return values
string —getValueFromOperatorLike()
Return value for LIKE operator.
private
getValueFromOperatorLike(string $value) : string
Parameters
- $value : string