Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. QueryInterface.php

function 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')->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.

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 257

Class

QueryInterface
Interface for entity queries.

Namespace

Drupal\Core\Entity\Query

Code

public function andConditionGroup();

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal