ConditionTree
Handles filtering conditions for Query and join conditions for Entity References.
Tags
Table of Contents
Constants
Methods
- __clone() : mixed
- __construct() : mixed
- ConditionTree constructor.
- addCondition() : $this
- Adds prepared condition.
- createFromArray() : ConditionTree
- Creates filter object from array
- getConditions() : array<string|int, ConditionTree>|array<string|int, Condition>
- Returns all conditions and subfilters.
- getSql() : string
- Returns SQL for all conditions and subfilters.
- hasConditions() : bool
- Checks if filter is not empty.
- logic() : $this|string
- All conditions will be imploded by this logic: static::LOGIC_AND or static::LOGIC_OR
- negative() : $this
- Sets NOT before all the conditions.
- removeAllConditions() : mixed
- Removes all conditions
- removeCondition() : bool
- Removes one condition
- replaceCondition() : bool
- Replaces condition with a new one.
- where() : $this
- General condition. In regular case used with 3 parameters: where(columnName, operator, value), e.g. ('ID', '=', 1); ('SALARY', '>', '500')
- whereBetween() : $this
- BETWEEN condition.
- whereColumn() : $this
- The same logic as where(), but value will be taken as another column name.
- whereExists() : $this
- Exists() condition. Can be used with Query object or plain sql wrapped with SqlExpression.
- whereExpr() : $this
- Any SQL Expression condition
- whereIn() : $this
- IN() condition.
- whereLike() : $this
- LIKE condition, without default % placement.
- whereMatch() : $this
- Fulltext search condition.
- whereNot() : $this
- Sets NOT before any conditions or subfilter.
- whereNotBetween() : $this
- Negative BETWEEN condition.
- whereNotExists() : $this
- Negative Exists() condition. Can be used with Query object or plain sql wrapped with SqlExpression.
- whereNotIn() : $this
- Negative IN() condition.
- whereNotLike() : $this
- Negative LIKE condition, without default % placement.
- whereNotMatch() : $this
- Negative fulltext search condition.
- whereNotNull() : $this
- Compares column with NOT NULL.
- whereNull() : $this
- Compares column with NULL.
Constants
LOGIC_AND
public
mixed
LOGIC_AND
= 'and'
LOGIC_OR
public
mixed
LOGIC_OR
= 'or'
Methods
__clone()
public
__clone() : mixed
__construct()
ConditionTree constructor.
public
__construct() : mixed
addCondition()
Adds prepared condition.
public
addCondition(Condition|ConditionTree $condition) : $this
Parameters
- $condition : Condition|ConditionTree
Tags
Return values
$thiscreateFromArray()
Creates filter object from array
public
static createFromArray(mixed $filter) : ConditionTree
Parameters
- $filter : mixed
Tags
Return values
ConditionTreegetConditions()
Returns all conditions and subfilters.
public
getConditions() : array<string|int, ConditionTree>|array<string|int, Condition>
Return values
array<string|int, ConditionTree>|array<string|int, Condition>getSql()
Returns SQL for all conditions and subfilters.
public
getSql(array<string|int, Chain> $chains) : string
Parameters
- $chains : array<string|int, Chain>
Tags
Return values
stringhasConditions()
Checks if filter is not empty.
public
hasConditions() : bool
Return values
boollogic()
All conditions will be imploded by this logic: static::LOGIC_AND or static::LOGIC_OR
public
logic([string $logic = null ]) : $this|string
Parameters
- $logic : string = null
-
and|or
Tags
Return values
$this|stringnegative()
Sets NOT before all the conditions.
public
negative([bool $negative = true ]) : $this
Parameters
- $negative : bool = true
Return values
$thisremoveAllConditions()
Removes all conditions
public
removeAllConditions() : mixed
removeCondition()
Removes one condition
public
removeCondition(mixed $condition) : bool
Parameters
- $condition : mixed
Return values
boolreplaceCondition()
Replaces condition with a new one.
public
replaceCondition(mixed $currentCondition, mixed $newCondition) : bool
Parameters
- $currentCondition : mixed
- $newCondition : mixed
Return values
boolwhere()
General condition. In regular case used with 3 parameters: where(columnName, operator, value), e.g. ('ID', '=', 1); ('SALARY', '>', '500')
public
where(mixed ...$filter) : $this
List of available operators can be found in Operator class.
Parameters
- $filter : mixed
Tags
Return values
$thiswhereBetween()
BETWEEN condition.
public
whereBetween(mixed $column, mixed $valueMin, mixed $valueMax) : $this
Parameters
- $column : mixed
- $valueMin : mixed
- $valueMax : mixed
Return values
$thiswhereColumn()
The same logic as where(), but value will be taken as another column name.
public
whereColumn(mixed ...$filter) : $this
Parameters
- $filter : mixed
Tags
Return values
$thiswhereExists()
Exists() condition. Can be used with Query object or plain sql wrapped with SqlExpression.
public
whereExists(Query|SqlExpression $query) : $this
Parameters
- $query : Query|SqlExpression
Return values
$thiswhereExpr()
Any SQL Expression condition
public
whereExpr(string $expr, array<string|int, string> $arguments) : $this
Parameters
- $expr : string
- $arguments : array<string|int, string>
Tags
Return values
$thiswhereIn()
IN() condition.
public
whereIn(string $column, array<string|int, mixed>|Query|SqlExpression $values) : $this
Parameters
- $column : string
- $values : array<string|int, mixed>|Query|SqlExpression
Return values
$thiswhereLike()
LIKE condition, without default % placement.
public
whereLike(mixed $column, mixed $value) : $this
Parameters
- $column : mixed
- $value : mixed
Return values
$thiswhereMatch()
Fulltext search condition.
public
whereMatch(mixed $column, mixed $value) : $this
Parameters
- $column : mixed
- $value : mixed
Tags
Return values
$thiswhereNot()
Sets NOT before any conditions or subfilter.
public
whereNot(mixed ...$filter) : $this
Parameters
- $filter : mixed
Tags
Return values
$thiswhereNotBetween()
Negative BETWEEN condition.
public
whereNotBetween(mixed $column, mixed $valueMin, mixed $valueMax) : $this
Parameters
- $column : mixed
- $valueMin : mixed
- $valueMax : mixed
Tags
Return values
$thiswhereNotExists()
Negative Exists() condition. Can be used with Query object or plain sql wrapped with SqlExpression.
public
whereNotExists(Query|SqlExpression $query) : $this
Parameters
- $query : Query|SqlExpression
Tags
Return values
$thiswhereNotIn()
Negative IN() condition.
public
whereNotIn(string $column, array<string|int, mixed>|Query|SqlExpression $values) : $this
Parameters
- $column : string
- $values : array<string|int, mixed>|Query|SqlExpression
Tags
Return values
$thiswhereNotLike()
Negative LIKE condition, without default % placement.
public
whereNotLike(mixed $column, mixed $value) : $this
Parameters
- $column : mixed
- $value : mixed
Tags
Return values
$thiswhereNotMatch()
Negative fulltext search condition.
public
whereNotMatch(mixed $column, mixed $value) : $this
Parameters
- $column : mixed
- $value : mixed
Tags
Return values
$thiswhereNotNull()
Compares column with NOT NULL.
public
whereNotNull(string $column) : $this
Parameters
- $column : string
Return values
$thiswhereNull()
Compares column with NULL.
public
whereNull(string $column) : $this
Parameters
- $column : string