Bitrix API

ConditionTree

Handles filtering conditions for Query and join conditions for Entity References.

Tags
subpackage

main

Table of Contents

Constants

LOGIC_AND  = 'and'
LOGIC_OR  = 'or'

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

Methods

__construct()

ConditionTree constructor.

public __construct() : mixed

createFromArray()

Creates filter object from array

public static createFromArray(mixed $filter) : ConditionTree
Parameters
$filter : mixed
Tags
throws
ArgumentException
Return values
ConditionTree

getSql()

Returns SQL for all conditions and subfilters.

public getSql(array<string|int, Chain$chains) : string
Parameters
$chains : array<string|int, Chain>
Tags
throws
ArgumentException
throws
SystemException
Return values
string

hasConditions()

Checks if filter is not empty.

public hasConditions() : bool
Return values
bool

logic()

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
throws
ArgumentException
Return values
$this|string

negative()

Sets NOT before all the conditions.

public negative([bool $negative = true ]) : $this
Parameters
$negative : bool = true
Return values
$this

removeAllConditions()

Removes all conditions

public removeAllConditions() : mixed

removeCondition()

Removes one condition

public removeCondition(mixed $condition) : bool
Parameters
$condition : mixed
Return values
bool

replaceCondition()

Replaces condition with a new one.

public replaceCondition(mixed $currentCondition, mixed $newCondition) : bool
Parameters
$currentCondition : mixed
$newCondition : mixed
Return values
bool

where()

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
see
Operator::$operators

Can be used in short format: where(columnName, value), with operator '=' by default Can be used in ultra short format: where(columnName), for boolean fields only

Can be used for subfilter set: where(ConditionTree subfilter)

Instead of columnName, you can use runtime field: where(new ExpressionField('TMP', 'CONCAT(%s, %s)', ["NAME", "LAST_NAME"]), 'Anton Ivanov') or with expr helper where(Query::expr()->concat("NAME", "LAST_NAME"), 'Anton Ivanov')

throws
ArgumentException
Return values
$this

whereBetween()

BETWEEN condition.

public whereBetween(mixed $column, mixed $valueMin, mixed $valueMax) : $this
Parameters
$column : mixed
$valueMin : mixed
$valueMax : mixed
Return values
$this

whereColumn()

The same logic as where(), but value will be taken as another column name.

public whereColumn(mixed ...$filter) : $this
Parameters
$filter : mixed
Tags
see
ConditionTree::where()
throws
ArgumentException
Return values
$this

whereExpr()

Any SQL Expression condition

public whereExpr(string $expr, array<string|int, string> $arguments) : $this
Parameters
$expr : string
$arguments : array<string|int, string>
Tags
see
ExpressionField
throws
ArgumentException
throws
SystemException
Return values
$this

whereLike()

LIKE condition, without default % placement.

public whereLike(mixed $column, mixed $value) : $this
Parameters
$column : mixed
$value : mixed
Return values
$this

whereMatch()

Fulltext search condition.

public whereMatch(mixed $column, mixed $value) : $this
Parameters
$column : mixed
$value : mixed
Tags
see
Helper::matchAgainstWildcard()

for preparing $value for AGAINST.

Return values
$this

whereNot()

Sets NOT before any conditions or subfilter.

public whereNot(mixed ...$filter) : $this
Parameters
$filter : mixed
Tags
see
ConditionTree::where()
Return values
$this

whereNotBetween()

Negative BETWEEN condition.

public whereNotBetween(mixed $column, mixed $valueMin, mixed $valueMax) : $this
Parameters
$column : mixed
$valueMin : mixed
$valueMax : mixed
Tags
see
ConditionTree::whereBetween()
Return values
$this

whereNotLike()

Negative LIKE condition, without default % placement.

public whereNotLike(mixed $column, mixed $value) : $this
Parameters
$column : mixed
$value : mixed
Tags
see
ConditionTree::whereLike()
Return values
$this

whereNotMatch()

Negative fulltext search condition.

public whereNotMatch(mixed $column, mixed $value) : $this
Parameters
$column : mixed
$value : mixed
Tags
see
Helper::matchAgainstWildcard()

for preparing $value for AGAINST.

Return values
$this

whereNotNull()

Compares column with NOT NULL.

public whereNotNull(string $column) : $this
Parameters
$column : string
Return values
$this

whereNull()

Compares column with NULL.

public whereNull(string $column) : $this
Parameters
$column : string
Return values
$this

        
On this page

Search results