/**
  * {@inheritdoc}
  */
 public function applyConditions(ISelectBuilder $selectBuilder)
 {
     $selectBuilder->begin($this->mode);
     foreach ($this->conditions as $fieldCondition) {
         $fieldCondition->apply($selectBuilder);
     }
     foreach ($this->getGroups() as $nextGroup) {
         $nextGroup->applyConditions($selectBuilder);
     }
     $selectBuilder->end();
     return $this;
 }
Example #2
0
 /**
  * Строит часть ограничительную часть запроса
  * @param ISelectBuilder $query
  * @return string
  */
 private function buildLimitPart(ISelectBuilder $query)
 {
     $limitSql = '';
     if ($query->getLimit()) {
         $limitSql = "\nLIMIT " . $query->getLimit();
         if ($query->getOffset()) {
             $limitSql .= " OFFSET " . $query->getOffset();
         }
     }
     return $limitSql;
 }
Example #3
0
 /**
  * Применяет ограничения на выборку
  * @param ISelectBuilder $selectBuilder
  */
 protected function applyLimitConditions(ISelectBuilder $selectBuilder)
 {
     if ($this->limit) {
         $postfix = self::PLACEHOLDER_SEPARATOR . $this->collection->getName();
         $limitPlaceholder = ':limit' . $postfix;
         $selectBuilder->limit($limitPlaceholder)->bindInt($limitPlaceholder, $this->limit);
         if ($this->offset) {
             $offsetPlaceholder = ':offset' . $postfix;
             $selectBuilder->offset($offsetPlaceholder)->bindInt($offsetPlaceholder, $this->offset);
         }
     }
 }
Example #4
0
 /**
  * Прнименяет условие на выборку "BETWEEN"
  * @param ISelectBuilder $selectBuilder
  * @return $this
  */
 protected function applyBetweenCondition(ISelectBuilder $selectBuilder)
 {
     list($minValue, $maxValue) = $this->expression;
     $minPlaceholder = $this->placeholder . ISelector::PLACEHOLDER_SEPARATOR . 'min';
     $maxPlaceholder = $this->placeholder . ISelector::PLACEHOLDER_SEPARATOR . 'max';
     $selectBuilder->begin()->expr($this->fieldColumn, IFieldCondition::OPERATOR_EQMORE, $minPlaceholder)->expr($this->fieldColumn, IFieldCondition::OPERATOR_EQLESS, $maxPlaceholder)->bindValue($minPlaceholder, $minValue, $this->field->getDataType())->bindValue($maxPlaceholder, $maxValue, $this->field->getDataType())->end();
     return $this;
 }