function QueryBase::andConditionGroup

Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/Query/QueryBase.php \Drupal\Core\Entity\Query\QueryBase::andConditionGroup()
  2. 10 core/lib/Drupal/Core/Entity/Query/QueryBase.php \Drupal\Core\Entity\Query\QueryBase::andConditionGroup()
  3. 11.x core/lib/Drupal/Core/Entity/Query/QueryBase.php \Drupal\Core\Entity\Query\QueryBase::andConditionGroup()

Creates a new group of conditions ANDed together.

For example, consider a drawing entity type with a 'figures' multi-value field containing 'shape' and 'color' columns. To find all drawings containing both a red triangle and a blue circle:

$query = \Drupal::entityQuery('drawing')->accessCheck(FALSE);
$group = $query->andConditionGroup()
    ->condition('figures.color', 'red')
    ->condition('figures.shape', 'triangle');
$query->condition($group);
$group = $query->andConditionGroup()
    ->condition('figures.color', 'blue')
    ->condition('figures.shape', 'circle');
$query->condition($group);
$entity_ids = $query->execute();

Return value

\Drupal\Core\Entity\Query\ConditionInterface A condition object whose conditions will be combined with AND.

Overrides QueryInterface::andConditionGroup

File

core/lib/Drupal/Core/Entity/Query/QueryBase.php, line 223

Class

QueryBase
The base entity query class.

Namespace

Drupal\Core\Entity\Query

Code

public function andConditionGroup() {
    return $this->conditionGroupFactory('and');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.