/** * Returns a statement for an expression. * * @param QueryBuilder $queryBuilder * * @return string */ public function getStatement(QueryBuilder $queryBuilder) { $paramName1 = $this->getFieldName() . $this->getUniqueId(); $paramName2 = $this->getFieldName() . $this->getUniqueId(); $queryBuilder->setParameter($paramName1, $this->getStart()); $queryBuilder->setParameter($paramName2, $this->getEnd()); return $this->field->getSelect() . ' BETWEEN :' . $paramName1 . ' AND :' . $paramName2; }
/** * {@inheritdoc} */ public function getStatement(QueryBuilder $queryBuilder) { $paramName = $this->getFieldName() . $this->getUniqueId(); if ($this->getValue() === null) { return $this->field->getSelect() . ' ' . $this->convertNullComparator($this->getComparator()); } elseif ($this->getComparator() === 'LIKE') { $queryBuilder->setParameter($paramName, '%' . $this->getValue() . '%'); } else { $queryBuilder->setParameter($paramName, $this->getValue()); } return $this->field->getSelect() . ' ' . $this->getComparator() . ' :' . $paramName; }
/** * {@inheritdoc} */ public function getStatement(QueryBuilder $queryBuilder) { $paramName = $this->getFieldName() . $this->getUniqueId(); $values = $this->filterNullValues($this->getValues()); $statement = ''; if (count($values) > 0) { $queryBuilder->setParameter($paramName, $values); $statement = $this->field->getSelect() . ' IN (:' . $paramName . ')'; if (array_search(null, $this->getValues())) { $statement .= ' OR ' . $this->field->getSelect() . ' IS NULL'; } } elseif (array_search(null, $this->getValues())) { // only null in values array $statement .= $paramName . ' IS NULL'; } return $statement; }
/** * {@inheritdoc} */ public function getStatement(QueryBuilder $queryBuilder) { $paramName = $this->getFieldName() . $this->getUniqueId(); if ($this->getValue() === null) { return $this->field->getSelect() . ' ' . $this->convertNullComparator($this->getComparator()); } elseif ($this->getComparator() === 'LIKE') { $queryBuilder->setParameter($paramName, '%' . $this->getValue() . '%'); } elseif (in_array($this->getComparator(), ['and', 'or']) && is_array($this->getValue())) { $statement = []; $value = $this->getValue(); for ($i = 0, $count = count($value); $i < $count; ++$i) { $statement[] = sprintf('%s = :%s%s', $this->field->getWhere(), $paramName, $i); $queryBuilder->setParameter($paramName . $i, $value[$i]); } return implode(' ' . $this->getComparator() . ' ', $statement); } else { $queryBuilder->setParameter($paramName, $this->getValue()); } return $this->field->getWhere() . ' ' . $this->getComparator() . ' :' . $paramName; }
/** * Returns the select statement for this field without the alias. * * @return string */ public function getSelect() { return 'GROUP_CONCAT(' . $this->fieldDescriptor->getSelect() . ' SEPARATOR \'' . $this->glue . '\')'; }
/** * {@inheritDoc} */ public function execute() { $this->queryBuilder = $this->createQueryBuilder(); foreach ($this->fields as $field) { $this->queryBuilder->addSelect($field->getSelect() . ' AS ' . $field->getName()); } if ($this->limit != null) { $this->queryBuilder->setMaxResults($this->limit)->setFirstResult($this->limit * ($this->page - 1)); } if ($this->sortField != null) { $this->queryBuilder->orderBy($this->sortField->getSelect(), $this->sortOrder); } return $this->queryBuilder->getQuery()->getArrayResult(); }