You are here

public function QueryInterface::andConditionGroup in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Entity/Query/QueryInterface.php \Drupal\Core\Entity\Query\QueryInterface::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');
$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

1 method overrides QueryInterface::andConditionGroup()
QueryBase::andConditionGroup in core/lib/Drupal/Core/Entity/Query/QueryBase.php
Creates a new group of conditions ANDed together.

File

core/lib/Drupal/Core/Entity/Query/QueryInterface.php, line 198
Contains \Drupal\Core\Entity\Query\QueryInterface.

Class

QueryInterface
Interface for entity queries.

Namespace

Drupal\Core\Entity\Query

Code

public function andConditionGroup();