You are here

public function name_handler_filter_name_fulltext::op_word in Name Field 7

File

includes/name_handler_filter_name_fulltext.inc, line 103

Class

name_handler_filter_name_fulltext
Field handler to provide simple renderer that allows linking to a entity.

Code

public function op_word($fulltext_field) {
  $where = $this->operator == 'word' ? db_or() : db_and();

  // Don't filter on empty strings.
  if (empty($this->value)) {
    return;
  }
  $value = drupal_strtolower($this->value);
  $words = preg_split('/ /', $value, -1, PREG_SPLIT_NO_EMPTY);
  foreach ($words as $word) {
    $placeholder = $this
      ->placeholder();
    $where
      ->where("{$fulltext_field} LIKE {$placeholder}", array(
      $placeholder => '% ' . db_like($word) . '%',
    ));
  }
  $this->query
    ->add_where($this->options['group'], $where);
}