The Expression Builder is a convenient fluent interface for
building expressions to be used with the Doctrine\Common\Collections\Criteria
class:
1 | $expressionBuilder = Criteria::expr();
$criteria = new Criteria();
$criteria->where($expressionBuilder->eq('name', 'jwage'));
$criteria->orWhere($expressionBuilder->eq('name', 'romanb'));
$collection->matching($criteria); |
2 |
3 |
4 |
5 |
6 |
7 |
The ExpressionBuilder
has the following API:
1 | $expressionBuilder = Criteria::expr();
$expression = $expressionBuilder->andX(
$expressionBuilder->eq('foo', 1),
$expressionBuilder->eq('bar', 1)
);
$collection->matching(new Criteria($expression)); |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
1 | $expressionBuilder = Criteria::expr();
$expression = $expressionBuilder->orX(
$expressionBuilder->eq('foo', 1),
$expressionBuilder->eq('bar', 1)
);
$collection->matching(new Criteria($expression)); |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
1 | $expressionBuilder = Criteria::expr();
$expression = $expressionBuilder->eq('foo', 1);
$collection->matching(new Criteria($expression)); |
2 |
3 |
4 |
5 |
1 | $expressionBuilder = Criteria::expr();
$expression = $expressionBuilder->gt('foo', 1);
$collection->matching(new Criteria($expression)); |
2 |
3 |
4 |
5 |
1 | $expressionBuilder = Criteria::expr();
$expression = $expressionBuilder->lt('foo', 1);
$collection->matching(new Criteria($expression)); |
2 |
3 |
4 |
5 |
1 | $expressionBuilder = Criteria::expr();
$expression = $expressionBuilder->gte('foo', 1);
$collection->matching(new Criteria($expression)); |
2 |
3 |
4 |
5 |
1 | $expressionBuilder = Criteria::expr();
$expression = $expressionBuilder->lte('foo', 1);
$collection->matching(new Criteria($expression)); |
2 |
3 |
4 |
5 |
1 | $expressionBuilder = Criteria::expr();
$expression = $expressionBuilder->neq('foo', 1);
$collection->matching(new Criteria($expression)); |
2 |
3 |
4 |
5 |
1 | $expressionBuilder = Criteria::expr();
$expression = $expressionBuilder->isNull('foo');
$collection->matching(new Criteria($expression)); |
2 |
3 |
4 |
5 |
1 | $expressionBuilder = Criteria::expr();
$expression = $expressionBuilder->in('foo', ['value1', 'value2']);
$collection->matching(new Criteria($expression)); |
2 |
3 |
4 |
5 |
1 | $expressionBuilder = Criteria::expr();
$expression = $expressionBuilder->notIn('foo', ['value1', 'value2']);
$collection->matching(new Criteria($expression)); |
2 |
3 |
4 |
5 |
1 | $expressionBuilder = Criteria::expr();
$expression = $expressionBuilder->contains('foo', 'value1');
$collection->matching(new Criteria($expression)); |
2 |
3 |
4 |
5 |
1 | $expressionBuilder = Criteria::expr();
$expression = $expressionBuilder->memberOf('foo', ['value1', 'value2']);
$collection->matching(new Criteria($expression)); |
2 |
3 |
4 |
5 |
1 | $expressionBuilder = Criteria::expr();
$expression = $expressionBuilder->startsWith('foo', 'hello');
$collection->matching(new Criteria($expression)); |
2 |
3 |
4 |
5 |
1 | $expressionBuilder = Criteria::expr();
$expression = $expressionBuilder->endsWith('foo', 'world');
$collection->matching(new Criteria($expression)); |
2 |
3 |
4 |
5 |