/** * {@inheritdoc} */ public function query($group_by = FALSE) { $this->fillValue(); $condition_operator = empty($this->options['not']) ? '=' : '<>'; if (count($this->value) > 1) { $conditions = $this->query->createConditionGroup(Unicode::strtoupper($this->operator)); // $conditions will be NULL if there were errors in the query. if ($conditions) { foreach ($this->value as $value) { $conditions->addCondition($this->realField, $value, $condition_operator); } $this->query->addConditionGroup($conditions); } } else { $this->query->addCondition($this->realField, reset($this->value), $condition_operator); } }
/** * {@inheritdoc} */ public function query() { if ($this->operator === 'empty') { $this->query->addCondition($this->realField, NULL, '=', $this->options['group']); } elseif ($this->operator === 'not empty') { $this->query->addCondition($this->realField, NULL, '<>', $this->options['group']); } elseif (is_array($this->value)) { $all_of = $this->operator === 'all of'; $operator = $all_of ? '=' : $this->operator; if (count($this->value) == 1) { $this->query->addCondition($this->realField, reset($this->value), $operator, $this->options['group']); } else { $conditions = $this->query->createConditionGroup($operator === '<>' || $all_of ? 'AND' : 'OR'); foreach ($this->value as $value) { $conditions->addCondition($this->realField, $value, $operator); } $this->query->addConditionGroup($conditions, $this->options['group']); } } }