function QueryBase::orConditionGroup
Same name and namespace in other branches
- 8.9.x core/lib/Drupal/Core/Entity/Query/QueryBase.php \Drupal\Core\Entity\Query\QueryBase::orConditionGroup()
- 10 core/lib/Drupal/Core/Entity/Query/QueryBase.php \Drupal\Core\Entity\Query\QueryBase::orConditionGroup()
- 11.x core/lib/Drupal/Core/Entity/Query/QueryBase.php \Drupal\Core\Entity\Query\QueryBase::orConditionGroup()
Creates a new group of conditions ORed together.
For example, consider a map entity with an 'attributes' field containing 'building_type' and 'color' columns. To find all green and red bikesheds:
$query = \Drupal::entityQuery('map')->accessCheck(FALSE);
$group = $query->orConditionGroup()
->condition('attributes.color', 'red')
->condition('attributes.color', 'green');
$entity_ids = $query->condition('attributes.building_type', 'bikeshed')
->condition($group)
->execute();
Note that this particular example can be simplified:
$entity_ids = $query->condition('attributes.color', [
'red',
'green',
])
->condition('attributes.building_type', 'bikeshed')
->execute();
Return value
\Drupal\Core\Entity\Query\ConditionInterface A condition object whose conditions will be combined with OR.
Overrides QueryInterface::orConditionGroup
File
-
core/
lib/ Drupal/ Core/ Entity/ Query/ QueryBase.php, line 230
Class
- QueryBase
- The base entity query class.
Namespace
Drupal\Core\Entity\QueryCode
public function orConditionGroup() {
return $this->conditionGroupFactory('or');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.