public function Fulltext::op_word in Name Field 8
The word operation.
Parameters
string $fulltext_field: The db field.
File
- src/
Plugin/ views/ filter/ Fulltext.php, line 148
Class
- Fulltext
- Filter by fulltext search.
Namespace
Drupal\name\Plugin\views\filterCode
public function op_word($fulltext_field) {
$where = $this->operator == 'word' ? new Condition('OR') : new Condition('AND');
$value = mb_strtolower($this->value[0]);
$words = preg_split('/ /', $value, -1, PREG_SPLIT_NO_EMPTY);
foreach ($words as $word) {
$placeholder = $this
->placeholder();
$where
->where("{$fulltext_field} LIKE {$placeholder}", [
$placeholder => '% ' . $this->connection
->escapeLike($word) . '%',
]);
}
$this->query
->addWhere($this->options['group'], $where);
}