You are here

function tweet_feed_handler_argument_hashtag::query in Tweet Feed 6

File

inc/tweet_feed_handler_argument_hashtag.inc, line 19

Class

tweet_feed_handler_argument_hashtag
override the string handler for handling hash tags as we need to change the query so we can look through the string with a LIKE instead of an =

Code

function query($group_by = FALSE) {
  if (empty($this->options['match_exact'])) {
    $argument = '%' . $this->argument . '%';
  }
  else {
    $argument = ' ' . $this->argument . ' ';
  }
  $this->value = array(
    $argument,
  );
  $this->operator = 'or';
  $this
    ->ensure_my_table();
  $formula = FALSE;
  $field = "{$this->table_alias}.{$this->real_field}";
  if (count($this->value) > 1) {
    $operator = 'IN';
    $argument = $this->value;
  }
  else {
    if (empty($this->options['match_exact'])) {
      $operator = 'LIKE';
    }
    else {
      $operator = 'REGEXP';
    }
  }
  $this->query
    ->add_where(0, "{$field} {$operator} '%s'", $argument);
}