setWhereGroup example

// Don't filter on empty strings.     if (empty($this->value)) {
      return;
    }

    // Match all words separated by spaces or sentences encapsulated by double     // quotes.     preg_match_all(static::WORDS_PATTERN, ' ' . $this->value, $matches, PREG_SET_ORDER);

    // Switch between the 'word' and 'allwords' operator.     $type = $this->operator == 'word' ? 'OR' : 'AND';
    $group = $this->query->setWhereGroup($type);
    $operator = $this->getConditionOperator('LIKE');

    foreach ($matches as $match_key => $match) {
      $temp_placeholder = $placeholder . '_' . $match_key;
      // Clean up the user input and remove the sentence delimiters.       $word = trim($match[2], ',?!();:-"');
      $this->query->addWhereExpression($group, "$expression $operator $temp_placeholder", [$temp_placeholder => '%' . $this->connection->escapeLike($word) . '%']);
    }
  }

  protected function opStartsWith($expression) {
    

  public function addWhere($group$field$value = NULL, $operator = NULL) {
    // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all     // the default group.     if (empty($group)) {
      $group = 0;
    }

    // Check for a group.     if (!isset($this->where[$group])) {
      $this->setWhereGroup('AND', $group);
    }

    $this->where[$group]['conditions'][] = [
      'field' => $field,
      'value' => $value,
      'operator' => $operator,
    ];
  }

  /** * Adds a complex WHERE clause to the query. * * The caller is responsible for ensuring that all fields are fully qualified * (TABLE.FIELD) and that the table already exists in the query. * Internally the dbtng method "where" is used. * * @param $group * The WHERE group to add these to; groups are used to create AND/OR * sections. Groups cannot be nested. Use 0 as the default group. * If the group does not yet exist it will be created as an AND group. * @param $snippet * The snippet to check. This can be either a column or * a complex expression like "UPPER(table.field) = 'value'" * @param $args * An associative array of arguments. * * @see QueryConditionInterface::where() */


    // Build all the relationships first thing.     $this->_build('relationship');

    // Set the filtering groups.     if (!empty($this->filter)) {
      $filter_groups = $this->display_handler->getOption('filter_groups');
      if ($filter_groups) {
        $this->query->setGroupOperator($filter_groups['operator']);
        foreach ($filter_groups['groups'] as $id => $operator) {
          $this->query->setWhereGroup($operator$id);
        }
      }
    }

    // Build all the filters.     $this->_build('filter');

    $this->build_sort = TRUE;

    // Arguments can, in fact, cause this whole thing to abort.     if (!$this->_buildArguments()) {
      
Home | Imprint | This part of the site doesn't use cookies.