Trait QueryFilterTrait
Methods summary
public
Cake\ORM\Query
|
#
fieldsFilter( Cake\ORM\Query $query, array $options )
Create query filter using various operators on fields
Options array must contain fields as keys and operators like
- 'gt' or '>' (greather than)
- 'lt' or '<' (less than),
- 'ge' or '>=' (greater or equal)
- 'le' or '<=' (less or equal) with a date
Create query filter using various operators on fields
Options array must contain fields as keys and operators like
- 'gt' or '>' (greather than)
- 'lt' or '<' (less than),
- 'ge' or '>=' (greater or equal)
- 'le' or '<=' (less or equal) with a date
It's also possible to specify an expected value or a list of values for a field
Options array examples:
['field1' => ['gt' => 10], 'field2' => ['lt' => 5]];
['field1' => [1, 3, 10]];
['field1' => '1,3,10'];
['field1' => 10, 'field1' => ['eq' => 1]];
['field1' => ['>=' => 10], 'field2' => ['<=' => 4]];
['field1' => ['null' => 1], 'field2' => ['null' => 0], 'field3' => null];
//
Parameters
- $query
- Query object instance.
- $options
- Array of acceptable fields and conditions.
Returns
Cake\ORM\Query
|
protected
Cake\Database\Expression\QueryExpression
|
#
operatorExpression( Cake\Database\Expression\QueryExpression $exp, string $operator, string $field, string $value )
Get query expression for an operator on a field with a value.
Unrecognized operators are ignored and have no effect.
Get query expression for an operator on a field with a value.
Unrecognized operators are ignored and have no effect.
Parameters
- $exp
- Current query expression
- $operator
- Filter operator
- $field
- Filter field
- $value
- Filter value
Returns
Cake\Database\Expression\QueryExpression Operator query expression
|