/** * Match a row against a group of conditions. * * @param \Drupal\Core\Database\Driver\fake\DatabaseRowInterface $row * The database row object. * @param \Drupal\Core\Database\Query\Condition $condition_group * The condition group object. * * @return bool * TRUE if there is a match. */ public static function matchGroup(DatabaseRowInterface $row, Condition $condition_group) { $conditions = $condition_group->conditions(); $and = $conditions['#conjunction'] == 'AND'; unset($conditions['#conjunction']); $match = TRUE; foreach ($conditions as $condition) { $match = $condition['field'] instanceof Condition ? static::matchGroup($row, $condition['field']) : static::matchSingle($row, $condition); // For AND, finish matching on the first fail. For OR, finish on first // success. if ($and != $match) { break; } } return $match; }
/** * Implements Drupal\Core\Database\Query\ConditionInterface::conditions(). */ public function &conditions() { return $this->condition->conditions(); }
/** * Gets a list of all conditions in the HAVING clause. * * This method returns by reference. That allows alter hooks to access the * data structure directly and manipulate it before it gets compiled. * * @return array * An array of conditions. * * @see \Drupal\Core\Database\Query\ConditionInterface::conditions() */ public function &havingConditions() { return $this->having->conditions(); }
private function GetUsedAliases(DatabaseCondition $condition, array &$aliases = array()) { foreach($condition->conditions() as $key => $c) { if (is_string($key) && substr($key, 0, 1) == '#') { continue; } if (is_a($c['field'], DatabaseCondition::class)) { $this->GetUsedAliases($c['field'], $aliases); } else { $aliases[$c['field']] = TRUE; } } }